-
Notifications
You must be signed in to change notification settings - Fork 1
Creating Commands
Commando treats each file as a command, with the functions being subcommands. The file just needs to be marked as a command.
This can be done using the Command
annotation, or a registerCommando
function.
Kotlin
@file:Command("example")
package me.honkling.example.commands
private fun example(player: Player) {
// ...
}
Java
@Command("example")
public class Example {
public void example(Player player) {
// ...
}
}
Kotlin
private fun registerCommando(manager: CommandManager) {
manager.registerCommand("example")
}
Java
public class Example {
public void registerCommando(CommandManager manager) {
manager.registerCommand("example");
}
}
You may set various properties of the command, such as description, permissions, etc., using the annotation or registerCommando
function mentioned above. They are just properties in the constructor.
Aliases
Annotation: @Command("example", "alias1", "alias2", ...)
Method: manager.registerCommand("example", "alias1", "alias2", ...)
Description
Annotation: @Command("example", description = "hello")
Method: manager.registerCommand("example", description = "hello")
Usage
Annotation: @Command("example", usage = "you ran it wrong")
Method: manager.registerCommand("example", usage = "you ran it wrong")
Usage handler (method exclusive): manager.registerCommand("example", usageHandler = { command: PluginCommand -> /* ... */ })
Permission
Annotation: @Command("example", permission = "commando.example")
Method: manager.registerCommand("example", permission = "commando.example")
Permission Message
Annotation: @Command("example", permissionMessage = "You don't have permission")
Method: manager.registerCommand("example", permissionMessage = "You don't have permission")
Commando treats every function as a subcommand, using the name of the function to name the subcommand.
Do note, if the function is named the same as the command itself, then it is treated as the default subcommand, meaning it can be executed with just /<command name>
, as opposed to /<command name> <function name>
.