CommandAPI 9.5.2
An API for the command UI introduced in Minecraft 1.13
com.mojang.brigadier.arguments.ArgumentType< T > Interface Template Reference

A parsable argument designed to be used by an ArgumentCommandNode as its type argument. More...

Public Member Functions

parse (StringReader reader) throws CommandSyntaxException
 Parses the given StringReader to an instance of this argument's generic type. More...
 
default< S > CompletableFuture< SuggestionslistSuggestions (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...
 

Detailed Description

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.

Parameters
<T>the type of the argument

Member Function Documentation

◆ getExamples()

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.

Returns
a collection with a few examples for valid type arguments @implSpec The default implementation returns an emtpy immutable collection.

◆ listSuggestions()

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.

Parameters
contextthe context to get them for
builderthe suggestions builder to add them to
Returns
a future that will eventually resolve into a Suggestions object @implSpec The default implementation simply returns an empty suggestions object

◆ parse()

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.

Parameters
readerthe read to read from
Returns
the parsed argument
Exceptions
CommandSyntaxExceptionif the argument is malformed