diff --git a/guide/docs/commands/brigardier_example.md b/guide/docs/commands/brigardier_example.md new file mode 100644 index 00000000..f0af1a8c --- /dev/null +++ b/guide/docs/commands/brigardier_example.md @@ -0,0 +1,19 @@ +The following command illustrates how to use commands, subcommands, arguments and the command context. + +```kotlin +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 } + } + } + } + } +} +``` diff --git a/guide/mkdocs.yml b/guide/mkdocs.yml index eab546fc..e923d39a 100644 --- a/guide/mkdocs.yml +++ b/guide/mkdocs.yml @@ -43,5 +43,6 @@ nav: - Compounds: gui/compounds.md - Commands: - Brigardier: commands/brigardier.md + - Brigardier example: commands/brigardier_example.md - Migration: - "1.16 -> 1.17": migration/1_16_to_1_17.md