summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDico Karssiens <dico.karssiens@gmail.com>2018-09-30 17:05:42 +0100
committerDico Karssiens <dico.karssiens@gmail.com>2018-09-30 17:05:42 +0100
commitc4801757a2fda147e1cee65f70f80fb215047525 (patch)
treecc19a113ede79396b56b0adb0ebdb12d63613e2f /src
parent7f36b6f561e17fa76c184053d46254faff69142b (diff)
Some changes
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt16
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/ParcelCommandBuilder.kt5
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/ParcelCommandReceivers.kt2
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt4
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/ParcelTarget.kt2
-rw-r--r--src/main/kotlin/io/dico/parcels2/defaultimpl/DefaultParcelGenerator.kt1
-rw-r--r--src/main/kotlin/io/dico/parcels2/defaultimpl/ParcelProviderImpl.kt11
-rw-r--r--src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt2
-rw-r--r--src/main/kotlin/io/dico/parcels2/storage/Hikari.kt2
9 files changed, 22 insertions, 23 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt b/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt
index bcc7997..eaa9f57 100644
--- a/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt
@@ -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) \ No newline at end of file
diff --git a/src/main/kotlin/io/dico/parcels2/command/ParcelCommandBuilder.kt b/src/main/kotlin/io/dico/parcels2/command/ParcelCommandBuilder.kt
index 2777b7f..721ce2d 100644
--- a/src/main/kotlin/io/dico/parcels2/command/ParcelCommandBuilder.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/ParcelCommandBuilder.kt
@@ -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))
diff --git a/src/main/kotlin/io/dico/parcels2/command/ParcelCommandReceivers.kt b/src/main/kotlin/io/dico/parcels2/command/ParcelCommandReceivers.kt
index 8f6dabc..15548b4 100644
--- a/src/main/kotlin/io/dico/parcels2/command/ParcelCommandReceivers.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/ParcelCommandReceivers.kt
@@ -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.*
diff --git a/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt b/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt
index 736e568..a9f5498 100644
--- a/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt
@@ -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)
}
diff --git a/src/main/kotlin/io/dico/parcels2/command/ParcelTarget.kt b/src/main/kotlin/io/dico/parcels2/command/ParcelTarget.kt
index 70a8dda..8891912 100644
--- a/src/main/kotlin/io/dico/parcels2/command/ParcelTarget.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/ParcelTarget.kt
@@ -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("/")
diff --git a/src/main/kotlin/io/dico/parcels2/defaultimpl/DefaultParcelGenerator.kt b/src/main/kotlin/io/dico/parcels2/defaultimpl/DefaultParcelGenerator.kt
index e9ec148..9e43c05 100644
--- a/src/main/kotlin/io/dico/parcels2/defaultimpl/DefaultParcelGenerator.kt
+++ b/src/main/kotlin/io/dico/parcels2/defaultimpl/DefaultParcelGenerator.kt
@@ -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
diff --git a/src/main/kotlin/io/dico/parcels2/defaultimpl/ParcelProviderImpl.kt b/src/main/kotlin/io/dico/parcels2/defaultimpl/ParcelProviderImpl.kt
index 74545d6..48a7fee 100644
--- a/src/main/kotlin/io/dico/parcels2/defaultimpl/ParcelProviderImpl.kt
+++ b/src/main/kotlin/io/dico/parcels2/defaultimpl/ParcelProviderImpl.kt
@@ -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) }
}
}
diff --git a/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt b/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt
index 04941b4..59d10e7 100644
--- a/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt
+++ b/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt
@@ -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,
diff --git a/src/main/kotlin/io/dico/parcels2/storage/Hikari.kt b/src/main/kotlin/io/dico/parcels2/storage/Hikari.kt
index d1500d5..480d533 100644
--- a/src/main/kotlin/io/dico/parcels2/storage/Hikari.kt
+++ b/src/main/kotlin/io/dico/parcels2/storage/Hikari.kt
@@ -32,7 +32,7 @@ fun getHikariConfig(dialectName: String,
username = dco.username
password = dco.password
connectionTimeout = 15000
- leakDetectionThreshold = 30000
+ leakDetectionThreshold = 10000
connectionTestQuery = "SELECT 1"