Some changes
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package io.dico.parcels2.command
|
||||
|
||||
import io.dico.dicore.command.CommandException
|
||||
import io.dico.dicore.command.EMessageType
|
||||
import io.dico.dicore.command.ExecutionContext
|
||||
import io.dico.dicore.command.ICommandReceiver
|
||||
import io.dico.dicore.command.*
|
||||
import io.dico.dicore.command.registration.reflect.ICommandInterceptor
|
||||
import io.dico.dicore.command.registration.reflect.ICommandReceiver
|
||||
import io.dico.parcels2.*
|
||||
import io.dico.parcels2.PlayerProfile.Real
|
||||
import io.dico.parcels2.PlayerProfile.Unresolved
|
||||
@@ -13,13 +12,16 @@ import org.bukkit.entity.Player
|
||||
import org.bukkit.plugin.Plugin
|
||||
import java.lang.reflect.Method
|
||||
|
||||
abstract class AbstractParcelCommands(val plugin: ParcelsPlugin) : ICommandReceiver.Factory {
|
||||
override fun getPlugin(): Plugin = plugin
|
||||
abstract class AbstractParcelCommands(val plugin: ParcelsPlugin) : ICommandInterceptor {
|
||||
|
||||
override fun getReceiver(context: ExecutionContext, target: Method, cmdName: String): ICommandReceiver {
|
||||
return getParcelCommandReceiver(plugin.parcelProvider, context, target, cmdName)
|
||||
}
|
||||
|
||||
override fun getCoroutineContext(context: ExecutionContext?, target: Method?, cmdName: String?): Any {
|
||||
return plugin.coroutineContext
|
||||
}
|
||||
|
||||
protected fun checkConnected(action: String) {
|
||||
if (!plugin.storage.isConnected) err("Parcels cannot $action right now because of a database error")
|
||||
}
|
||||
@@ -57,8 +59,6 @@ abstract class AbstractParcelCommands(val plugin: ParcelsPlugin) : ICommandRecei
|
||||
.format(progress * 100, elapsedTime / 1000.0)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getCoroutineContext() = plugin.coroutineContext
|
||||
}
|
||||
|
||||
fun err(message: String): Nothing = throw CommandException(message)
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.dico.parcels2.command
|
||||
|
||||
import io.dico.dicore.command.*
|
||||
import io.dico.dicore.command.parameter.ArgumentBuffer
|
||||
import io.dico.dicore.command.predef.DefaultGroupCommand
|
||||
import io.dico.dicore.command.registration.reflect.ReflectiveRegistration
|
||||
import io.dico.parcels2.Interactables
|
||||
@@ -107,10 +108,12 @@ class SpecialCommandAddress : ChildCommandAddress() {
|
||||
}
|
||||
}
|
||||
|
||||
// h:1
|
||||
@Throws(CommandException::class)
|
||||
override fun getChild(key: String, context: ExecutionContext): ChildCommandAddress? {
|
||||
override fun getChild(context: ExecutionContext, buffer: ArgumentBuffer): ChildCommandAddress? {
|
||||
speciallyParsedIndex = null
|
||||
|
||||
val key = buffer.next() ?: return null
|
||||
for (specialKey in speciallyTreatedKeys) {
|
||||
if (key.startsWith(specialKey)) {
|
||||
val result = getChild(specialKey.substring(0, specialKey.length - 1))
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.dico.parcels2.command
|
||||
|
||||
import io.dico.dicore.command.CommandException
|
||||
import io.dico.dicore.command.ExecutionContext
|
||||
import io.dico.dicore.command.ICommandReceiver
|
||||
import io.dico.dicore.command.registration.reflect.ICommandReceiver
|
||||
import io.dico.dicore.command.Validate
|
||||
import io.dico.parcels2.*
|
||||
import io.dico.parcels2.Privilege.*
|
||||
|
||||
@@ -30,7 +30,7 @@ class ParcelParameterType(val parcelProvider: ParcelProvider) : ParameterType<Pa
|
||||
val regex = Regex.fromLiteral("((.+)->)?([0-9]+):([0-9]+)")
|
||||
|
||||
override fun parse(parameter: Parameter<Parcel, Void>, sender: CommandSender, buffer: ArgumentBuffer): Parcel {
|
||||
val matchResult = regex.matchEntire(buffer.next())
|
||||
val matchResult = regex.matchEntire(buffer.next()!!)
|
||||
?: invalidInput(parameter, "must match (w->)?a:b (/${regex.pattern}/)")
|
||||
|
||||
val world = parcelProvider.getTargetWorld(matchResult.groupValues[2], sender, parameter)
|
||||
@@ -66,7 +66,7 @@ class ProfileParameterType : ParameterType<PlayerProfile, Int>(PlayerProfile::cl
|
||||
val allowReal = (info and REAL) != 0
|
||||
val allowFake = (info and FAKE) != 0
|
||||
|
||||
val input = buffer.next()
|
||||
val input = buffer.next()!!
|
||||
return PlayerProfile.byName(input, allowReal, allowFake)
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ sealed class ParcelTarget(val world: ParcelWorld, val parsedKind: Int, val isDef
|
||||
ParameterType<ParcelTarget, Int>(ParcelTarget::class.java, TargetKind) {
|
||||
|
||||
override fun parse(parameter: Parameter<ParcelTarget, Int>, sender: CommandSender, buffer: ArgumentBuffer): ParcelTarget {
|
||||
var input = buffer.next()
|
||||
var input = buffer.next()!!
|
||||
val worldString = input.substringBefore("/", missingDelimiterValue = "")
|
||||
input = input.substringAfter("/")
|
||||
|
||||
|
||||
@@ -279,7 +279,6 @@ class DefaultParcelGenerator(
|
||||
val region = getRegion(parcel)
|
||||
val blocks = parcelTraverser.traverseRegion(region)
|
||||
val blockCount = region.blockCount.toDouble()
|
||||
|
||||
val world = world
|
||||
val floorHeight = o.floorHeight
|
||||
val airType = airType
|
||||
|
||||
@@ -50,7 +50,7 @@ class ParcelProviderImpl(val plugin: ParcelsPlugin) : ParcelProvider {
|
||||
return
|
||||
}
|
||||
|
||||
//val newlyCreatedWorlds = mutableListOf<ParcelWorld>()
|
||||
val newlyCreatedWorlds = mutableListOf<ParcelWorld>()
|
||||
for ((worldName, worldOptions) in options.worlds.entries) {
|
||||
var parcelWorld = _worlds[worldName]
|
||||
if (parcelWorld != null) continue
|
||||
@@ -70,7 +70,7 @@ class ParcelProviderImpl(val plugin: ParcelsPlugin) : ParcelProvider {
|
||||
val time = DateTime.now()
|
||||
plugin.storage.setWorldCreationTime(parcelWorld.id, time)
|
||||
parcelWorld.creationTime = time
|
||||
//newlyCreatedWorlds.add(parcelWorld)
|
||||
newlyCreatedWorlds.add(parcelWorld)
|
||||
} else {
|
||||
GlobalScope.launch(context = Dispatchers.Unconfined) {
|
||||
parcelWorld.creationTime = plugin.storage.getWorldCreationTime(parcelWorld.id).await() ?: DateTime.now()
|
||||
@@ -80,10 +80,10 @@ class ParcelProviderImpl(val plugin: ParcelsPlugin) : ParcelProvider {
|
||||
_worlds[worldName] = parcelWorld
|
||||
}
|
||||
|
||||
loadStoredData()
|
||||
loadStoredData(newlyCreatedWorlds.toSet())
|
||||
}
|
||||
|
||||
private fun loadStoredData() {
|
||||
private fun loadStoredData(newlyCreatedWorlds: Collection<ParcelWorld> = emptyList()) {
|
||||
plugin.launch(Dispatchers.Default) {
|
||||
val migration = plugin.options.migration
|
||||
if (migration.enabled) {
|
||||
@@ -105,9 +105,8 @@ class ParcelProviderImpl(val plugin: ParcelsPlugin) : ParcelProvider {
|
||||
val channel = plugin.storage.transmitAllParcelData()
|
||||
while (true) {
|
||||
val (id, data) = channel.receiveOrNull() ?: break
|
||||
if (data == null) continue
|
||||
val parcel = getParcelById(id) ?: continue
|
||||
parcel.copyData(data, callerIsDatabase = true)
|
||||
data?.let { parcel.copyData(it, callerIsDatabase = true) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,6 @@ class ParcelListeners(
|
||||
newTo = newTo.add(it, delta * 100 * if (it == Dimension.Y) 0.5 else speed)
|
||||
}
|
||||
|
||||
|
||||
|
||||
event.to = Location(
|
||||
toLoc.world,
|
||||
newTo.x, newTo.y.clampMin(0.0).clampMax(255.0), newTo.z,
|
||||
|
||||
@@ -32,7 +32,7 @@ fun getHikariConfig(dialectName: String,
|
||||
username = dco.username
|
||||
password = dco.password
|
||||
connectionTimeout = 15000
|
||||
leakDetectionThreshold = 30000
|
||||
leakDetectionThreshold = 10000
|
||||
connectionTestQuery = "SELECT 1"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user