From 8d4bea2bb043d435db5430f6f9c2e61bf7e41c2f Mon Sep 17 00:00:00 2001 From: Jakob K Date: Mon, 28 Jun 2021 13:16:12 +0200 Subject: [PATCH] Add brigardier example to the guide --- guide/docs/commands/brigardier_example.md | 19 +++++++++++++++++++ guide/mkdocs.yml | 1 + 2 files changed, 20 insertions(+) create mode 100644 guide/docs/commands/brigardier_example.md 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