CommandAPI 9.5.2
An API for the command UI introduced in Minecraft 1.13
|
A parsable argument designed to be used by an ArgumentCommandNode
as its type argument.
More...
Public Member Functions | |
T | parse (StringReader reader) throws CommandSyntaxException |
Parses the given StringReader to an instance of this argument's generic type. More... | |
default< S > CompletableFuture< Suggestions > | listSuggestions (final CommandContext< S > context, final SuggestionsBuilder builder) |
Gets suggestions for a parsed input string on what comes next. More... | |
default Collection< String > | getExamples () |
Provides examples of valid arguments that are used by CommandDispatcher#findAmbiguities to find ambiguities. More... | |
A parsable argument designed to be used by an ArgumentCommandNode
as its type argument.
As different commands need different arguments (string, integer, long, double,…), this interface provides a way to define parsers for each of them.
<T> | the type of the argument |
default Collection< String > com.mojang.brigadier.arguments.ArgumentType< T >.getExamples | ( | ) |
Provides examples of valid arguments that are used by CommandDispatcher#findAmbiguities
to find ambiguities.
No guarantees about the mutability of the returned collection are made.
default< S > CompletableFuture< Suggestions > com.mojang.brigadier.arguments.ArgumentType< T >.listSuggestions | ( | final CommandContext< S > | context, |
final SuggestionsBuilder | builder | ||
) |
Gets suggestions for a parsed input string on what comes next.
As it is ultimately up to custom argument types to provide suggestions, it may be an asynchronous operation, for example getting in-game data or player names etc. As such, this method returns a future and no guarantees are made to when or how the future completes.
The suggestions provided will be in the context of the end of the parsed input string, but may suggest new or replacement strings for earlier in the input string. For example, if the end of the string was foobar
but an argument preferred it to be minecraft:foobar
, it will suggest a replacement for that whole segment of the input.
context | the context to get them for |
builder | the suggestions builder to add them to |
Suggestions
object @implSpec The default implementation simply returns an empty suggestions object T com.mojang.brigadier.arguments.ArgumentType< T >.parse | ( | StringReader | reader | ) | throws CommandSyntaxException |
Parses the given StringReader
to an instance of this argument's generic type.
For example, if this this is an ArgumentType<Integer>
this would return an Integer.
reader | the read to read from |
CommandSyntaxException | if the argument is malformed |