Complex Command
With this mechanism, you can easily create commands that have many subcommands
You can create object, that will be annotated by @Command. You can use other annotations (such as @Usage) from Annotations
In object you can declare functions. you can work with functions the same way as with regular command functions, but use @SubCommand instead of @Command for subcommands. You can also specify which function will be executed if no sub-command is found, annotate such a function using @Default
Don't forget to register the object in the CommandManager
Example
fun KotlinPlugin.onEnable() {
commandManager().register(AdvancedCommand)
}
@Command ("adv")
@Permission( "test.advanted")
object AdvancedCommand {
@Default
fun default(sender: CommandSender) {
sender.sendMessage("def")
}
@SubCommand("subl")
fun sub1(sender: CommandSender) {
sender.sendMessage("subl executed")
}
@SubCommand("sub2")
fun sub2(sender: CommandSender, arg: String) {
sender.sendMessage("subl executed with arg $arg")
}
}Last updated