diff options
author | Dico <dico.karssiens@gmail.com> | 2018-08-02 03:42:48 +0100 |
---|---|---|
committer | Dico <dico.karssiens@gmail.com> | 2018-08-02 03:42:48 +0100 |
commit | 6513ad9237dbda0244a52608ae639fee5822b3ee (patch) | |
tree | 1cde86912f1131d7a318687a8fcca9ba9b2f568a /src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt | |
parent | 3917855a72c60d1c78632949b4fea21471873347 (diff) |
Fix bugs
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt b/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt index 929b0c7..bfa1f6c 100644 --- a/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt +++ b/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt @@ -8,16 +8,12 @@ import io.dico.dicore.command.annotation.Flag import io.dico.dicore.command.annotation.RequireParameters import io.dico.parcels2.ParcelOwner import io.dico.parcels2.ParcelsPlugin -import io.dico.parcels2.blockvisitor.RegionTraversal import io.dico.parcels2.storage.getParcelBySerializedValue import io.dico.parcels2.util.hasAdminManage import io.dico.parcels2.util.hasParcelHomeOthers import io.dico.parcels2.util.uuid -import org.bukkit.Material import org.bukkit.entity.Player -import java.util.* -//@Suppress("unused") class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { @Cmd("auto") @@ -26,7 +22,7 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { shortVersion = "sets you up with a fresh, unclaimed parcel") suspend fun WorldScope.cmdAuto(player: Player): Any? { checkConnected("be claimed") - checkParcelLimit(player) + checkParcelLimit(player, world) val parcel = world.nextEmptyParcel() ?: error("This world is full, please ask an admin to upsize it") @@ -58,7 +54,7 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { val ownedParcels = ownedParcelsResult .map { worlds.getParcelBySerializedValue(it) } - .filter { it != null && ownerTarget.world == it.world && ownerTarget.owner == it.owner } + .filter { it != null && ownerTarget.world == it.world } val targetMatch = ownedParcels.getOrNull(target.index) ?: error("The specified parcel could not be matched") @@ -76,11 +72,19 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { error(if (it.matches(player)) "You already own this parcel" else "This parcel is not available") } - checkParcelLimit(player) + checkParcelLimit(player, world) parcel.owner = ParcelOwner(player) return "Enjoy your new parcel!" } + @Cmd("unclaim") + @Desc("Unclaims this parcel") + @ParcelRequire(owner = true) + fun ParcelScope.cmdUnclaim(player: Player): Any? { + parcel.dispose() + return "Your parcel has been disposed" + } + @Cmd("clear") @ParcelRequire(owner = true) fun ParcelScope.cmdClear(context: ExecutionContext, @Flag sure: Boolean): Any? { @@ -101,23 +105,4 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { TODO() } - @Cmd("make_mess") - @ParcelRequire(owner = true) - fun ParcelScope.cmdMakeMess(context: ExecutionContext) { - val server = plugin.server - val blockDatas = arrayOf( - server.createBlockData(Material.STICKY_PISTON), - server.createBlockData(Material.GLASS), - server.createBlockData(Material.STONE_SLAB), - server.createBlockData(Material.QUARTZ_BLOCK) - ) - val random = Random() - world.generator.doBlockOperation(parcel, direction = RegionTraversal.UPDARD) { block -> - block.blockData = blockDatas[random.nextInt(4)] - }.onProgressUpdate(1000, 1000) { progress, elapsedTime -> - context.sendMessage(EMessageType.INFORMATIVE, "Mess progress: %.02f%%, %.2fs elapsed" - .format(progress * 100, elapsedTime / 1000.0)) - } - } - }
\ No newline at end of file |