CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
|
A CommandNode
that is triggered by an argument, like a number.
More...
Public Member Functions | |
ArgumentCommandNode (final String name, final ArgumentType< T > type, final Command< S > command, final Predicate< S > requirement, final CommandNode< S > redirect, final RedirectModifier< S > modifier, final boolean forks, final SuggestionProvider< S > customSuggestions) | |
ArgumentType< T > | getType () |
Returns the ArgumentType of this command. More... | |
String | getName () |
Returns the name of this command node. More... | |
String | getUsageText () |
Returns some usage text for this command node. More... | |
SuggestionProvider< S > | getCustomSuggestions () |
Returns the SuggestionProvider the command uses to advice the user on possible completions. More... | |
void | parse (final StringReader reader, final CommandContextBuilder< S > contextBuilder) throws CommandSyntaxException |
Tries to parse the command given by the reader and stores the results in the contextBuilder. More... | |
CompletableFuture< Suggestions > | listSuggestions (final CommandContext< S > context, final SuggestionsBuilder builder) throws CommandSyntaxException |
Lists suggestions for this command node, given the context and uses the passed SuggestionsBuilder to build them. More... | |
RequiredArgumentBuilder< S, T > | createBuilder () |
Creates a builder for this command node. More... | |
boolean | isValidInput (final String input) |
Checks if the given input is valid for this command node, i.e. More... | |
boolean | equals (final Object o) |
int | hashCode () |
Collection< String > | getExamples () |
Returns example usages for this command node, which are used to find ambiguities. More... | |
String | toString () |
Command< S > | getCommand () |
Returns the command to execute when executing this command node. More... | |
Collection< CommandNode< S > > | getChildren () |
Returns all child command nodes. More... | |
CommandNode< S > | getChild (final String name) |
Returns a child with the given getName . More... | |
CommandNode< S > | getRedirect () |
Returns the command node to redirect to. More... | |
RedirectModifier< S > | getRedirectModifier () |
Returns the redirect modifier to apply when redirecting. More... | |
boolean | canUse (final S source) |
Checks whether the given command source can use this command node. More... | |
void | addChild (final CommandNode< S > node) |
Adds a new child node to this command node. More... | |
void | findAmbiguities (final AmbiguityConsumer< S > consumer) |
Tries to find ambiguities in the children of this command node and recurses down. More... | |
Predicate< S > | getRequirement () |
Returns the requirement for this command node, that is used by canUse(Object) . More... | |
Collection<? extends CommandNode< S > > | getRelevantNodes (final StringReader input) |
Returns all relevant command nodes for the input, so all nodes that are probably able to parse the input. More... | |
int | compareTo (final CommandNode< S > o) |
boolean | isFork () |
Checks whether this command node forks. More... | |
Protected Member Functions | |
String | getSortedKey () |
Returns a key for this command node, that is used for ordering the command nodes. More... | |
A CommandNode
that is triggered by an argument, like a number.
The type of the argument is set via an ArgumentType
, which takes care of parsing the stringified argument passed by users.
A short example:
A subcommand for a delete command, taking the number of messages to delete. The ArgumentType
would be an IntegerArgumentType
then and the built command would parse things like "20" or "-230".
<S> | the type of the command source |
<T> | the ArgumentType the built command will use |
|
inherited |
Adds a new child node to this command node.
This will replace a command node with the same name, but there exist some bugs and some design decisions are not final as of now. Subsequently the exact behaviour in this case is not mandated. For a more detailed post about the problems, read this github issue.
You are not allowed to add children to commands with a getRedirect()
target!
node | the child command node to add |
UnsupportedOperationException | if you try to add a RootCommandNode to any other command node |
|
inherited |
Checks whether the given command source can use this command node.
This just checks the getRequirement()
predicate, which could e.g. check for permissions.
source | the command source to check for |
RequiredArgumentBuilder< S, T > com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.createBuilder | ( | ) |
Creates a builder for this command node.
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
boolean com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.equals | ( | final Object | o | ) |
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
|
inherited |
Tries to find ambiguities in the children of this command node and recurses down.
This can be used to detect whether multiple paths could be taken with a single input, which is not an ideal state for parsing commands. See CommandDispatcher#findAmbiguities
for more information.
consumer | the AmbiguityConsumer to call when ambiguities are found |
|
inherited |
Returns a child with the given getName
.
name | the name of the child command node |
|
inherited |
Returns all child command nodes.
|
inherited |
Returns the command to execute when executing this command node.
SuggestionProvider< S > com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.getCustomSuggestions | ( | ) |
Returns the SuggestionProvider
the command uses to advice the user on possible completions.
SuggestionProvider
or null if none Collection< String > com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.getExamples | ( | ) |
Returns example usages for this command node, which are used to find ambiguities.
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
String com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.getName | ( | ) |
Returns the name of this command node.
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
|
inherited |
Returns the command node to redirect to.
|
inherited |
Returns the redirect modifier to apply when redirecting.
|
inherited |
Returns all relevant command nodes for the input, so all nodes that are probably able to parse the input.
input | the input to check for |
|
inherited |
Returns the requirement for this command node, that is used by canUse(Object)
.
canUse(Object)
|
protected |
Returns a key for this command node, that is used for ordering the command nodes.
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
ArgumentType< T > com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.getType | ( | ) |
Returns the ArgumentType
of this command.
ArgumentType
of this command String com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.getUsageText | ( | ) |
Returns some usage text for this command node.
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
int com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.hashCode | ( | ) |
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
|
inherited |
Checks whether this command node forks.
See CommandDispatcher#execute(ParseResults)
for an explanation of what it does.
boolean com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.isValidInput | ( | final String | input | ) |
Checks if the given input is valid for this command node, i.e.
if it is what the command expects.
This is used to find ambiguities.
input | the input to check |
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
CompletableFuture< Suggestions > com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.listSuggestions | ( | final CommandContext< S > | context, |
final SuggestionsBuilder | builder | ||
) | throws CommandSyntaxException |
Lists suggestions for this command node, given the context and uses the passed SuggestionsBuilder
to build them.
context | the CommandContext to use for finding suggestions |
builder | the suggestions builder |
CommandSyntaxException | if the command is not well formed |
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.
void com.mojang.brigadier.tree.ArgumentCommandNode< S, T >.parse | ( | final StringReader | reader, |
final CommandContextBuilder< S > | contextBuilder | ||
) | throws CommandSyntaxException |
Tries to parse the command given by the reader and stores the results in the contextBuilder.
reader | the reader to read from |
contextBuilder | the context builder to store the results in |
CommandSyntaxException | if the input was malformed |
Reimplemented from com.mojang.brigadier.tree.CommandNode< S >.