diff --git a/docs/annotations/index.md b/docs/annotations/index.md index 3f0a252..f179fb9 100644 --- a/docs/annotations/index.md +++ b/docs/annotations/index.md @@ -84,6 +84,9 @@ instance of the class that you wish to parse. ## Command Methods +![Example Annotations](https://github.com/Incendo/cloud/blob/master/img/code/annotations_java_dark.png?raw=true#only-dark){ loading = lazy } +![Example Annotations](https://github.com/Incendo/cloud/blob/master/img/code/annotations_java_light.png?raw=true#only-light){ loading = lazy } + Command methods are annotated methods that are used to construct and handle commands. The method has to be annotated with a `@Command` annotation that specifies the command syntax. diff --git a/docs/assets/images/mce_help_1_dark.png b/docs/assets/images/mce_help_1_dark.png new file mode 100644 index 0000000..72fdef3 Binary files /dev/null and b/docs/assets/images/mce_help_1_dark.png differ diff --git a/docs/assets/images/mce_help_1_light.png b/docs/assets/images/mce_help_1_light.png new file mode 100644 index 0000000..f31fe4f Binary files /dev/null and b/docs/assets/images/mce_help_1_light.png differ diff --git a/docs/assets/images/mce_help_2_dark.png b/docs/assets/images/mce_help_2_dark.png new file mode 100644 index 0000000..e286cee Binary files /dev/null and b/docs/assets/images/mce_help_2_dark.png differ diff --git a/docs/assets/images/mce_help_2_light.png b/docs/assets/images/mce_help_2_light.png new file mode 100644 index 0000000..e93ba9e Binary files /dev/null and b/docs/assets/images/mce_help_2_light.png differ diff --git a/docs/core/index.md b/docs/core/index.md index 90fcdec..cb4a834 100644 --- a/docs/core/index.md +++ b/docs/core/index.md @@ -113,22 +113,8 @@ parsing and suggestion generation asynchronously. You may customize the asynchro ### Building a command - -!!! example - ```java - Command command = manager.commandBuilder("command") - .commandDescription(commandDescription("This is an example of a command")) - .literal("literal") - .required("string", stringParser(), description("A string")) - .literal("another-literal") - .optional("integer", integerParser(), description("An integer")) - .handler(context -> { - String string = context.get("string"); - int integer = context.getOrDefault("integer", 0); - // ... - }) - .build(); - ``` +![Example Builder](https://github.com/Incendo/cloud/blob/master/img/code/builder_java_dark.png?raw=true#only-dark) +![Example Builder](https://github.com/Incendo/cloud/blob/master/img/code/builder_java_light.png?raw=true#only-light) Commands are created using a command builder. You may either create a new builder by calling `Command.newBuilder` or through the command manager using diff --git a/docs/kotlin/index.md b/docs/kotlin/index.md index 31b9b9d..a3bfacf 100644 --- a/docs/kotlin/index.md +++ b/docs/kotlin/index.md @@ -1,5 +1,13 @@ # cloud-kotlin +The Kotlin modules allow you to write commands using Kotlin. There is support for both +builders, and annotated command methods. + +![Example Builder](https://github.com/Incendo/cloud/blob/master/img/code/builder_kotlin_dark.png?raw=true#only-dark){ loading = lazy } +![Example Builder](https://github.com/Incendo/cloud/blob/master/img/code/builder_kotlin_light.png?raw=true#only-light){ loading = lazy } +![Example Annotations](https://github.com/Incendo/cloud/blob/master/img/code/annotations_kotlin_dark.png?raw=true#only-dark){ loading = lazy } +![Example Annotations](https://github.com/Incendo/cloud/blob/master/img/code/annotations_kotlin_light.png?raw=true#only-light){ loading = lazy } + ## Modules
diff --git a/docs/minecraft/brigadier.md b/docs/minecraft/brigadier.md index e69de29..17dcc80 100644 --- a/docs/minecraft/brigadier.md +++ b/docs/minecraft/brigadier.md @@ -0,0 +1,5 @@ +# cloud-brigadier + +[Brigadier](https://github.com/mojang/brigadier) is Mojang's command system. Cloud integrates with Brigadier on platforms +where this is supported. Unless you want to create a platform integration it is unlikely that you will want to depend +on `cloud-brigadier` directly. Instead, you are able to interact with Brigadier through the platform integration. diff --git a/docs/minecraft/index.md b/docs/minecraft/index.md index ba6e9db..77c38c7 100644 --- a/docs/minecraft/index.md +++ b/docs/minecraft/index.md @@ -1 +1,18 @@ # cloud-minecraft + +## Modules + +
+ +- [Brigadier](./brigadier.md) +- [Minecraft Extras](./minecraft-extras.md) +- [Bukkit](./bukkit.md) +- [Paper](./paper.md) +- [Velocity](./velocity.md) +- [BungeeCord](./bungee.md) +- [NeoForge](./neoforge.md) +- [Fabric](./fabric.md) +- [Sponge](./sponge.md) +- [Cloudburst](./cloudburst.md) + +
diff --git a/docs/minecraft/minecraft-extras.md b/docs/minecraft/minecraft-extras.md index e69de29..cd0076e 100644 --- a/docs/minecraft/minecraft-extras.md +++ b/docs/minecraft/minecraft-extras.md @@ -0,0 +1,115 @@ +# cloud-minecraft-extras + +`cloud-minecraft-extras` contains some optional utilities for the Minecraft integrations. + +
+ +- [MinecraftHelp](#minecraft-help) +- [MinecraftExceptionHandler](#minecraft-exception-handler) +- [RichDescription](#rich-description) +- [TextColorParser](#text-color-parser) + +
+ + +!!! note + These utilities depend on [adventure](https://docs.advntr.dev/). You may need to depend on Adventure and shade it + into your project, depending on the platform you're targeting. Many Minecraft platforms, such as Paper, ship with + native implementations of Adventure, in which case you do not need to include it yourself. + +## Minecraft Help + +`MinecraftHelp` is an opinionated implementation of the [help system](../core/index.md#help-generation) using +Adventure components for styling and click handling. + +![Minecraft Help 1](../assets/images/mce_help_1_dark.png#only-dark) +![Minecraft Help 1](../assets/images/mce_help_1_light.png#only-light) +![Minecraft Help 2](../assets/images/mce_help_2_dark.png#only-dark) +![Minecraft Help 2](../assets/images/mce_help_2_light.png#only-light) + +All interactions with the Minecraft help system will take place through a `MinecraftHelp` instance. + +You may create an instance with the default styling: + + +=== "Native Audience" + + ```java + // Assuming YourSenderType extends Audience + MinecraftHelp help = MinecraftHelp.createNative( + "helpcommand", + commandManager + ); + ``` + +=== "Other" + + ```java + MinecraftHelp help = MinecraftHelp.create( + "helpcommand", + commandManager, + audienceMapper // YourSenderType -> Audience + ); + ``` + +or you may override the defaults by using a builder: + + +=== "Native Audience" + + ```java + MinecraftHelp help = MinecraftHelp.builder() + .commandManager(commandManager) + .audienceProvider(AudienceProvider.nativeProvider()) + .commandPrefix("/helpcommand") + /* other settings... */ + .build(); + ``` + +=== "Other" + + ```java + MinecraftHelp help = MinecraftHelp.builder() + .commandManager(commandManager) + .audienceProvider(yourAudienceProvider) + .commandPrefix("/helpcommand") + /* other settings... */ + .build(); + ``` + +You then want to invoke `MinecraftHelp.queryCommands(query, recipient)` in order to query the commands +and display the results to the recipient. + +```java title="Example Help Command" +commandManager.command( + commandManager.commandBuilder("helpcommand") + .optional("query", greedyStringParser(), DefaultValue.constant("")) + .handler(context -> { + help.queryCommands(context.get("query"), context.sender()); + }) +); +``` + +You may choose to add suggestions to the query argument as well: + +```java title="Query Suggestions" +.optional( + "query", + greedyStringParser(), + DefaultValue.constant(""), + SuggestionProvider.blocking((ctx, in) -> commandManager.createHelpHandler() + .queryRootIndex(ctx.sender()) + .entries() + .stream() + .map(CommandEntry::syntax) + .map(Suggestion::simple) + .collect(Collectors.toList()) + ) +) +``` + +## Minecraft Exception Handler + +## Rich Description + +## Text Color Parser