From b1011e0aaba61bb151246cae4f06b8bf0d8f6594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Tue, 28 Nov 2023 16:26:11 +0100 Subject: [PATCH] more scaffolding --- docs/core/index.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/docs/core/index.md b/docs/core/index.md index fd98d27..602b1a5 100644 --- a/docs/core/index.md +++ b/docs/core/index.md @@ -29,6 +29,7 @@ Cloud is available through [Maven Central](https://search.maven.org/search?q=clo ## Command A command is a chain of components. Each unique chain makes up a unique command. +A command can have some properties associated with it, such as a permission, description, etc. !!! example @@ -56,4 +57,99 @@ You may also not have two conflicting variable components on the same level, as which of them gets to parse the input. You may have _one_ variable component alongside literals, where the literals always get priority. +### Variable Components + +A variable component is associated with an output type. +It takes the incoming input and attempts to parse it into the output type using a parser. +See the section on [parsers](#parsers) for more information. + +#### Suggestions + +Cloud can generate suggestions for values which, depending on the platform, can be displayed +to the player to help them complete the command input. +Most standard parsers generate suggestions, and by default Cloud will ask the parser for suggestions. +You may provide your own suggestions using a suggestion provider. + ## Command Manager + +### Creating a command manager + +#### Execution coordinators + +### Building a command + +#### Descriptions + +#### Permissions + +#### Sender types + +#### Components + +#### Literals + +#### Variable + +##### Required + +##### Optional + +### Executing a command + +### Customizing the command manager + +#### Pre-processing + +#### Post-processing + +#### Exception handling + +## Extra + +### Configurations + +### Help generation + +## Parsers + +### Parser Registry + +### Standard Parsers + +#### String + +#### Character + +#### Numbers + +#### Boolean + +#### Enum + +### Flags + +### Aggregate Parsers + +Aggregate parsers are a new concept as of Cloud v2, and they supersede the old compound argument concept. +An aggregate parser is a combination of multiple parsers that maps the intermediate results into an output +type using a mapper. + +You may either implement the `AggregateCommandParser` interface, or using construct the parser by using a builder +that you create by calling `AggregateCommandParser.builder()`. + + +!!! example + ```java + final AggregateCommandParser locationParser = AggregateCommandParserbuilder() + .withComponent("world", worldParser()) + .withComponent("x", integerParser()) + .withComponent("y", integerParser()) + .withComponent("z", integerParser()) + .withMapper(Location.class, (commandContext, aggregateCommandContext) -> { + final World world = aggregateCommandContext.get("world"); + final int x = aggregateCommandContext.get("x"); + final int y = aggregateCommandContext.get("y"); + final int z = aggregateCommandContext.get("z"); + return CompletableFuture.completedFuture(new Location(world, x, y, z)); + }).build(); + ```