simple shop command
a command that gives out different items based on an argument
@Katton.command(name = "shop", permission = "all")
function shopCommand(sender, args) {
if (args.size() == 0) {
sender.sendMessage("&eavailable items: " + shopItems.keys())
return
}
val choice = args[0]
if (!shopItems.containsKey(choice)) {
sender.sendMessage("&cunknown item '" + choice + "'. Available: " + shopItems.keys())
return
}
val onCooldownUntil = Katton.vars.player(sender.uuid).get("shop_cooldown")
if (onCooldownUntil != null && onCooldownUntil == true) {
sender.sendMessage("&cyou're still on cooldown! try again in a moment")
return
}
val material = shopItems.get(choice)
sender.give(Katton.item(material))
sender.sendMessage("&ahere's your " + choice + "!")
Katton.vars.player(sender.uuid).set("shop_cooldown", true)
Katton.after(3.seconds) {
sender.sendMessage("&ayou're no longer on cooldown!")
Katton.vars.player(sender.uuid).set("shop_cooldown", false)
}
}
/katton run shop
/katton run shop sword
/katton run shop sword (immediately again shows the cooldown message)