CommandAPI 9.6.0
An API for the command UI introduced in Minecraft 1.13
|
A collection of Suggestion
s.
More...
Public Member Functions | |
Suggestions (final StringRange range, final List< Suggestion > suggestions) | |
StringRange | getRange () |
Returns the range the suggestions span. More... | |
List< Suggestion > | getList () |
Returns all suggestions as a list. More... | |
boolean | isEmpty () |
Checks if no suggestions are stored in this object. More... | |
boolean | equals (final Object o) |
int | hashCode () |
String | toString () |
Static Public Member Functions | |
static CompletableFuture< Suggestions > | empty () |
Returns a future that instantly completes with an empty Suggestions instance. More... | |
static Suggestions | merge (final String command, final Collection< Suggestions > input) |
Merges multiple Suggestions instances for a single command. More... | |
static Suggestions | create (final String command, final Collection< Suggestion > suggestions) |
Creates a Suggestions instance from a command and a list of possible Suggestions. More... | |
A collection of Suggestion
s.
|
static |
Creates a Suggestions instance from a command and a list of possible Suggestions.
The Suggestions instance will span the entire range, from the minimal index to maximum index found in the suggestions.
It will also automatically call Suggestion#expand
for every possible suggestion, using the command and the computed general range.
After all of that it sorts the results and returns them.
Some examples:
Suggestion foo = new Suggestion(StringRange.between(0, 2), "foo"); Suggestion bar = new Suggestion(StringRange.at(2), "bar"); Suggestions suggestions = Suggestions.create("1234567", List.of(foo, bar)); for (Suggestion suggestion : suggestions.getList()) { System.out.println(suggestion.apply("abcdefgh")); }
Prints:
(ordered alphabetically) 12barcdefgh (range expanded from 0 to 2, so it replaced "ab") foocdefgh (range was already 0 to 2, so nothing really changed)
command | the command to get them for |
suggestions | a list with possible suggestions |
|
static |
Returns a future that instantly completes with an empty Suggestions instance.
List< Suggestion > com.mojang.brigadier.suggestion.Suggestions.getList | ( | ) |
Returns all suggestions as a list.
StringRange com.mojang.brigadier.suggestion.Suggestions.getRange | ( | ) |
Returns the range the suggestions span.
boolean com.mojang.brigadier.suggestion.Suggestions.isEmpty | ( | ) |
Checks if no suggestions are stored in this object.
|
static |
Merges multiple Suggestions instances for a single command.
Just combines the input into one collection and then calls create
with the result.
command | the command |
input | the suggestions instances |