Skip to content

Commit 79df070

Browse files
committed
Wording changes
1 parent d53eaec commit 79df070

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

docs/paper/dev/api/command-api/basics/argument-suggestions.mdx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import GiveItemCommandMp4 from "./assets/give-item-command.mp4";
88
import SelectNameCommandMp4 from "./assets/select-name-command.mp4";
99

1010
# Argument Suggestions
11-
Sometimes, you want to send your own suggestions to users. For this, you can use the `RequiredArgumentBuilder#suggests(SuggestionProvider)` method.
11+
Sometimes, you want to send your own suggestions to users. For this, you can use the `suggests(SuggestionProvider<CommandSourceStack>)` method when declaring
12+
arguments.
1213

13-
## Examining the `SuggestionProvider<S>` method
14+
## Examining `SuggestionProvider<S>`
1415
The `SuggestionProvider<S>` interface is defined as follows:
1516

1617
```java title="SuggestionProvider.java"
@@ -20,26 +21,25 @@ public interface SuggestionProvider<S> {
2021
}
2122
```
2223

23-
Similar to other classes or interfaces with a `<S>` generic parameter, for Paper, this usually is a `CommandSourceStack`. Furthermore, similar to the `Command<S>` interface,
24+
Similar to other classes or interfaces with a `<S>` generic parameter, for Paper, this is usually a `CommandSourceStack`. Furthermore, similar to the `Command<S>` interface,
2425
this is a functional interface, which means that instead of passing in a class which implements this interface, we can just pass a lambda statement or a method reference.
2526

26-
Our lambda/method requires two parameters, `CommandContext<S>` and `SuggestionsBuilder`, returning a `CompletableFuture<Suggestions>`.
27-
In order to retrieve our return value, we can just run `SuggestionsBuilder#buildFuture()` (or `SuggestionsBuilder#build()`, if we already are inside a CompletableFuture).
27+
Our lambda consists of two parameters, `CommandContext<S>` and `SuggestionsBuilder`, and expects to have a `CompletableFuture<Suggestions>` returned.
2828

2929
A very simple lambda for our `suggests` method might look like this:
3030
```java
3131
Commands.argument("name", StringArgumentType.word())
32-
.suggests((ctx, builder) -> builder.buildFuture())
32+
.suggests((ctx, builder) -> builder.buildFuture());
3333
```
3434

35-
This example obviously does not suggest anything, as we haven't added suggestions yet.
35+
This example obviously does not suggest anything, as we haven't added any suggestions yet.
3636

37-
## A suggestion builder's methods
37+
## The `SuggestionBuilder`
3838
The `SuggestionsBuilder` has a few methods we can use to construct our suggestions:
3939

4040
### Input retrieval
4141
The first type of methods we will cover are the input retrieval methods: `getInput()`, `getStart()`, `getRemaining()`, and `getRemainingLowerCase()`.
42-
The following table displays what they return with the following input typed in the chat bar: `/customsuggestions Asumm13Text`.
42+
The following table displays what each returns with the following input typed in the chat bar: `/customsuggestions Asumm13Text`.
4343

4444
| Method | Return Value | Description |
4545
|----------------------------|--------------------------------|---------------------------------------------------------------|
@@ -49,19 +49,18 @@ The following table displays what they return with the following input typed in
4949
| getRemainingLowerCase() | asumm13text | The input for the current argument, lowercased |
5050

5151
### Suggestions
52-
The following overloads of the `SuggestionBuilder#suggest` method all add values that will be send to the client as suggestions, but accept
53-
difference parameters:
52+
The following overloads of the `SuggestionBuilder#suggest` method add values that will be send to the client as argument suggestions:
5453

5554
| Overload | Description |
5655
|--------------------------|-------------------------------------------------|
5756
| suggest(String) | Adds a String to the suggestions |
5857
| suggest(String, Message) | Adds a String with a tooltip to the suggestions |
5958
| suggest(int) | Adds an int to the suggestions |
60-
| suggest(int, Message) | Adds a String with a tooltip to the suggestions |
59+
| suggest(int, Message) | Adds an int with a tooltip to the suggestions |
6160

6261
There are two ways of retrieving a `Message` instance:
6362
- Using `LiteralMessage`, which can be used for basic, non-formatted text
64-
- Using the `MessageComponentSerializer`, with which you can serialize `Component` objects into `Message` objects.
63+
- Using the `MessageComponentSerializer`, which can be used to serialize `Component` objects into `Message` objects.
6564

6665
For example, if you add a suggestion like this:
6766
```java
@@ -74,12 +73,12 @@ It will look like this on the client:
7473
<img src={SuggestionTooltip} style={{width: "100%"}}/>
7574

7675
### Building
77-
There are two methods we can use to build our suggestions. The only difference between the both are that one directly returns the finished `Suggestions` object,
76+
There are two methods we can use to build our `Suggestions` object. The only difference between those is that one directly returns the finished `Suggestions` object,
7877
whilst the other one returns a `CompletableFuture<Suggestions>`.
7978

80-
The reason for these two methods is that the `SuggestionProvider`'s method requires the return value to be a `CompletableFuture<Suggestions>`. This for once
81-
allows for constructing your suggestions asynchronously inside a `CompletableFuture.supplyAsync(Supplier<Suggestions>)` or synchronously directly inside our
82-
lambda/method and only returning the final `Suggestions` object asynchronously.
79+
The reason for these two methods is that `SuggestionProvider` expects the return value to be `CompletableFuture<Suggestions>`. This for once
80+
allows for constructing your suggestions asynchronously inside a `CompletableFuture.supplyAsync(Supplier<Suggestions>)` statement, or synchronously directly inside our
81+
lambda and returning the final `Suggestions` object asynchronously.
8382

8483
Here are the same suggestions declared in the two different ways mentioned above:
8584
```java
@@ -102,8 +101,8 @@ Commands.argument("name", StringArgumentType.word())
102101
}));
103102
```
104103

105-
## Example: Suggesting amounts in a give command
106-
In commands where you give players certain items, you oftentimes include an amount argument. We could suggest `1`, `16`, `32`, and `64` as common amounts for
104+
## Example: Suggesting amounts in a give item command
105+
In commands, where you give players items, you oftentimes include an amount argument. We could suggest `1`, `16`, `32`, and `64` as common amounts for
107106
items given. The command implementation could look like this:
108107

109108
```java
@@ -196,5 +195,5 @@ public static LiteralCommandNode<CommandSourceStack> constructStringSuggestionsC
196195
}
197196
```
198197

199-
And as you can see in the preview below, this simple setup filters suggestions by user input, providing a smooth user experience when using your command:
198+
This simple setup filters suggestions by user input, providing a smooth user experience when running the command:
200199
<FullWidthVideo src={SelectNameCommandMp4}/>

0 commit comments

Comments
 (0)