diff options
author | Dico <dico.karssiens@gmail.com> | 2018-09-26 02:42:15 +0100 |
---|---|---|
committer | Dico <dico.karssiens@gmail.com> | 2018-09-26 02:42:15 +0100 |
commit | 2225bdae95b3de4985347edf30ae31a28f73f35b (patch) | |
tree | 3145fae97135d1864ea29c608be2917d74e2dadc /src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt | |
parent | dcd90c09add292300b163edf44c26ddf99f1199b (diff) |
Work on schematic and parcel swaps
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt b/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt index faafca9..6d62729 100644 --- a/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt +++ b/src/main/kotlin/io/dico/parcels2/command/AbstractParcelCommands.kt @@ -4,7 +4,7 @@ import io.dico.dicore.command.* import io.dico.parcels2.ParcelWorld import io.dico.parcels2.ParcelsPlugin import io.dico.parcels2.PlayerProfile -import io.dico.parcels2.PrivilegeChangeResult +import io.dico.parcels2.blockvisitor.Worker import io.dico.parcels2.util.ext.hasPermAdminManage import io.dico.parcels2.util.ext.parcelLimit import org.bukkit.entity.Player @@ -43,14 +43,17 @@ abstract class AbstractParcelCommands(val plugin: ParcelsPlugin) : ICommandRecei protected fun ParcelScope.clearWithProgressUpdates(context: ExecutionContext, action: String) { Validate.isTrue(!parcel.hasBlockVisitors, "A process is already running in this parcel") world.blockManager.clearParcel(parcel.id) - .onProgressUpdate(1000, 1000) { progress, elapsedTime -> - val alt = context.getFormat(EMessageType.NUMBER) - val main = context.getFormat(EMessageType.INFORMATIVE) - context.sendMessage( - EMessageType.INFORMATIVE, false, "$action progress: $alt%.02f$main%%, $alt%.2f${main}s elapsed" - .format(progress * 100, elapsedTime / 1000.0) - ) - } + } + + protected fun Worker.reportProgressUpdates(context: ExecutionContext, action: String) { + onProgressUpdate(1000, 1000) { progress, elapsedTime -> + val alt = context.getFormat(EMessageType.NUMBER) + val main = context.getFormat(EMessageType.INFORMATIVE) + context.sendMessage( + EMessageType.INFORMATIVE, false, "$action progress: $alt%.02f$main%%, $alt%.2f${main}s elapsed" + .format(progress * 100, elapsedTime / 1000.0) + ) + } } protected fun err(message: String): Nothing = throw CommandException(message) |