CommandAPI 9.5.2
An API for the command UI introduced in Minecraft 1.13
|
Represents a suggestion for a possible next value as well as an optional tooltip. More...
Public Member Functions | |
Suggestion (final StringRange range, final String text) | |
Creates a new Suggestion spanning the given string range in the input and that has a given text it suggests. More... | |
Suggestion (final StringRange range, final String text, final Message tooltip) | |
Creates a new Suggestion spanning the given string range in the input, with a given text it suggests and a tooltip it provides. More... | |
StringRange | getRange () |
Returns the range in the input string this suggestion is applicable in. More... | |
String | getText () |
Returns the text this suggestion suggests. More... | |
Message | getTooltip () |
Returns the tooltip with some explanatory message for the user. More... | |
String | apply (final String input) |
Applies the suggestion to the input. More... | |
boolean | equals (final Object o) |
int | hashCode () |
String | toString () |
int | compareTo (final Suggestion o) |
Compares the getText() of this suggestion to the getText() of the passed suggestion. More... | |
int | compareToIgnoreCase (final Suggestion b) |
Compares the getText() of this suggestion to the getText() of the passed suggestion, ignoring case. More... | |
Suggestion | expand (final String command, final StringRange range) |
Expands this suggestion by changing the range to the passed one and filling everything that lies outside getText() with characters from the passed command. More... | |
Represents a suggestion for a possible next value as well as an optional tooltip.
An example would be tab completion showing you the suggestions on the fly.
Instances of this class are compared based on the natural order of getText()
. A case insensitive comparison method is provided as compareToIgnoreCase(Suggestion)
.
com.mojang.brigadier.suggestion.Suggestion.Suggestion | ( | final StringRange | range, |
final String | text | ||
) |
Creates a new Suggestion spanning the given string range in the input and that has a given text it suggests.
range | the range in the input it is applicable in |
text | the replacement it suggests |
com.mojang.brigadier.suggestion.Suggestion.Suggestion | ( | final StringRange | range, |
final String | text, | ||
final Message | tooltip | ||
) |
Creates a new Suggestion spanning the given string range in the input, with a given text it suggests and a tooltip it provides.
range | the range in the input it is applicable in |
text | the replacement it suggests |
tooltip | some explanatory tooltip to show to the user, before they apply the suggestion |
String com.mojang.brigadier.suggestion.Suggestion.apply | ( | final String | input | ) |
Applies the suggestion to the input.
This method will replace or insert the getText()
into the passed input string.
An Example with the text fizz
:
buzz
, range 0-4 fizz
buzz
, range 0-0 fizzbuzz
buzz
, range 4-4 buzzfizz
input | the input string to apply it to |
StringIndexOutOfBoundsException | if the range is not contained in the input string |
int com.mojang.brigadier.suggestion.Suggestion.compareTo | ( | final Suggestion | o | ) |
Compares the getText()
of this suggestion to the getText()
of the passed suggestion.
This method is case sensitive, see compareToIgnoreCase(Suggestion)
if you need it to the ignore the case.
o | the suggestion to compare it to |
Reimplemented in com.mojang.brigadier.suggestion.IntegerSuggestion.
int com.mojang.brigadier.suggestion.Suggestion.compareToIgnoreCase | ( | final Suggestion | b | ) |
Compares the getText()
of this suggestion to the getText()
of the passed suggestion, ignoring case.
b | the suggestion to compare it to |
Reimplemented in com.mojang.brigadier.suggestion.IntegerSuggestion.
Suggestion com.mojang.brigadier.suggestion.Suggestion.expand | ( | final String | command, |
final StringRange | range | ||
) |
Expands this suggestion by changing the range to the passed one and filling everything that lies outside getText()
with characters from the passed command.
Examples with text = ----
and range = 0
and the text to apply it to as abcdefghi
:
expand("123", StringRange.at(0)
: ----abcdefghi
, as the ranges matched and so nothing was changed expand("123", StringRange.at(1)
: a----1bcdefghi
, as the passed range (1) was taken and one character from the command was used to fill up the index 1, as the range of the original suggestion was 0 expand("123", StringRange.between(1, 3)
: a----123defghi
, as the passed range (1,3) was taken and 3 characters from the command were used to fill up the indices 1, 2 and 3, as the range of the original suggestion was 0. It is then inserted after the first character in the text it is applied to (after the a) and replaces everything that lies in its interval (bc). command | the command to fill the range up with |
range | the range to widen it to |
StringRange com.mojang.brigadier.suggestion.Suggestion.getRange | ( | ) |
Returns the range in the input string this suggestion is applicable in.
String com.mojang.brigadier.suggestion.Suggestion.getText | ( | ) |
Returns the text this suggestion suggests.
Message com.mojang.brigadier.suggestion.Suggestion.getTooltip | ( | ) |
Returns the tooltip with some explanatory message for the user.