diff --git a/src/main/java/com/pokeskies/skiesclear/ClearTask.kt b/src/main/java/com/pokeskies/skiesclear/ClearTask.kt index fe7003b..8c37e5c 100644 --- a/src/main/java/com/pokeskies/skiesclear/ClearTask.kt +++ b/src/main/java/com/pokeskies/skiesclear/ClearTask.kt @@ -49,6 +49,14 @@ class ClearTask( } } + if (clearConfig.commands.clear.isNotEmpty()) { + for (command in clearConfig.commands.clear) { + if (server.commands.performPrefixedCommand(server.createCommandSourceStack(), command) == 0) { + Utils.printError("The post-clearing command \"$command\" failed to execute") + break + } + } + } if (broadcast && (clearConfig.messages.clear.isNotEmpty() || clearConfig.sounds.clear != null)) { for (player in server.playerList.players) { for (line in clearConfig.messages.clear) { @@ -69,6 +77,7 @@ class ClearTask( } } } + return totalCleared.get() } @@ -99,6 +108,15 @@ class ClearTask( ) } } + val warningCommands: List? = clearConfig.commands.warnings[timer.toString()] + if (warningCommands != null) { + for (command in warningCommands) { + if (server.commands.performPrefixedCommand(server.createCommandSourceStack(), command) == 0) { + Utils.printError("The ${timer}s warning command \"$command\" failed to execute") + break + } + } + } if (timer-- <= 0) { resetTimer() runClear(server, true) diff --git a/src/main/java/com/pokeskies/skiesclear/config/ClearConfig.kt b/src/main/java/com/pokeskies/skiesclear/config/ClearConfig.kt index 66e3bc0..8551c9f 100644 --- a/src/main/java/com/pokeskies/skiesclear/config/ClearConfig.kt +++ b/src/main/java/com/pokeskies/skiesclear/config/ClearConfig.kt @@ -14,6 +14,7 @@ class ClearConfig( val messages: Messages = Messages(), val sounds: Sounds = Sounds(), val clearables: Clearables? = null, + val commands: Commands = Commands(), ) { class Messages( @JsonAdapter(FlexibleListAdaptorFactory::class) @@ -56,6 +57,16 @@ class ClearConfig( } } + class Commands( + @JsonAdapter(FlexibleListAdaptorFactory::class) + val clear: List = emptyList(), + val warnings: Map> = emptyMap(), + ) { + override fun toString(): String { + return "Commands(clear=$clear, warnings=$warnings)" + } + } + override fun toString(): String { return "ClearConfig(enabled=$enabled, interval=$interval, dimensions=$dimensions, messages=$messages, sounds=$sounds, clearables=$clearables)" } diff --git a/src/main/resources/assets/skiesclear/config.json b/src/main/resources/assets/skiesclear/config.json index b7431db..6372912 100644 --- a/src/main/resources/assets/skiesclear/config.json +++ b/src/main/resources/assets/skiesclear/config.json @@ -46,6 +46,16 @@ } } }, + "commands": { + "clear": [ + ], + "warnings": { + "10": [ + ], + "5": [ + ] + } + }, "clearables": { "items": { "enabled": true,