diff options
author | Dico Karssiens <dico.karssiens@gmail.com> | 2018-07-30 14:52:36 +0100 |
---|---|---|
committer | Dico Karssiens <dico.karssiens@gmail.com> | 2018-07-30 14:52:36 +0100 |
commit | dbab42039432f1516ce64fc11b8af1f4d874576f (patch) | |
tree | 32340a758299e1b6484c4a2aca8a726131907b19 /src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt | |
parent | 48da05c9e866cbdfa3bdedb7d3ae35201993bf14 (diff) |
Set up clear performance test
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt b/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt index c3f8836..78a989e 100644 --- a/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt +++ b/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt @@ -7,12 +7,15 @@ import io.dico.dicore.command.annotation.Desc 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.command.NamedParcelDefaultValue.FIRST_OWNED 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) { @@ -81,12 +84,31 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { @Cmd("clear") @ParcelRequire(owner = true) - fun ParcelScope.cmdClear(player: Player, context: ExecutionContext) { + fun ParcelScope.cmdClear(context: ExecutionContext) { world.generator.clearParcel(parcel) .onProgressUpdate(1000, 1000) { progress, elapsedTime -> - context.sendMessage(EMessageType.INFORMATIVE, "Clear progress: %.06f%%, %.2fs elapsed" + context.sendMessage(EMessageType.INFORMATIVE, "Clear progress: %.02f%%, %.2fs elapsed" .format(progress * 100, elapsedTime / 1000.0)) } } + @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 |