Files
KSpigot/guide/docs/commands/brigardier_example.md
2021-06-28 13:16:12 +02:00

637 B

The following command illustrates how to use commands, subcommands, arguments and the command context.

command("gaming") {
    literal("set") {
        argument("state", BoolArgumentType.bool()) {
            simpleSuggests { listOf(true, false) }
            simpleExecutes {
                if (it.getArgument("state"))
                    it.source.bukkitSender.sendMessage("yoo gaming has been activated")
                else {
                    it.source.player.kill()
                    it.source.player.sendText("gaming disabled") { color = KColors.INDIANRED }
                }
            }
        }
    }
}