add notify + reject now throws

This commit is contained in:
Ceikry
2021-03-26 01:02:39 -05:00
parent 7f91f7c410
commit 4ffa4301ec
3 changed files with 17 additions and 7 deletions
@@ -25,7 +25,9 @@ class CommandSystem {
}
}
} else {
command.attemptHandling(player,arguments)
try {
command.attemptHandling(player, arguments)
} catch (e: IllegalStateException){return true}
}
return false
}
@@ -28,10 +28,19 @@ abstract class CommandSet(val defaultPrivilege: Command.Privilege) : Plugin<Any?
/**
* Glorified player.sendMessage with red text coloring. Please use this
* rather than just player.sendMessage for anything that involves informing the player
* of proper usage or invalid syntax.
* of proper usage or invalid syntax. Throws an IllegalStateException and ends command execution immediately.
*/
fun reject(player: Player, message: String){
player.sendMessage(colorize("%R$message"))
throw IllegalStateException()
}
/**
* Glorified player.sendMessage with green text coloring and an arrow. Use this when you need to
* notify/inform a player of some information from within the command without ending execution.
*/
fun notify(player: Player, message: String){
player.sendMessage(colorize("%G-->$message"))
}
/**