command annotation
@Katton.command(name = "name", permission = "admin" | "creative" | "all")
function handler(sender, args) {
...
}
requirements
- the function must take exactly two parameters:
senderandargs(you can name them whatever you like, but there must be exactly two) namemust be lowercase letters, numbers, underscores, and hyphens onlypermissionmust be exactly"admin","creative", or"all"
name uniqueness
@Katton.command(name = "heal", permission = "admin")
function heal1(sender, args) { ... }
@Katton.command(name = "heal", permission = "all") // will error due to having a duplicate within this script
function heal2(sender, args) { ... }
permission levels
args
everything typed after the command name in /katton run <name> [arguments...] comes through as a list of strings:
@Katton.command(name = "give", permission = "admin")
function giveByName(sender, args) {
if (args.size() == 0) {
sender.sendMessage("&cusage: /katton run give <material>")
return
}
val material = args[0]
sender.give(Katton.item(material))
}
/katton run give diamond_sword
here, args is ["diamond_sword"], so args[0] is "diamond_sword".