CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
|
An ArgumentBuilder
for a ArgumentCommandNode
that is triggered by an argument, like a number.
More...
Public Member Functions | |
RequiredArgumentBuilder< S, T > | suggests (final SuggestionProvider< S > provider) |
Sets the SuggestionProvider that provides the user with suggestions about what the next value could be. More... | |
SuggestionProvider< S > | getSuggestionsProvider () |
Returns the SuggestionProvider the command node uses to advice the user on possible completions. More... | |
ArgumentType< T > | getType () |
Returns the ArgumentType the built command node will use. More... | |
String | getName () |
Returns the name of the argument the built command node will have. More... | |
ArgumentCommandNode< S, T > | build () |
T | then (final ArgumentBuilder< S, ?> argument) |
Builds the given ArgumentBuilder and adds the result as new child node. More... | |
T | then (final CommandNode< S > argument) |
Adds the given command node as a child. More... | |
Collection< CommandNode< S > > | getArguments () |
Returns all registered child command nodes. More... | |
T | executes (final Command< S > command) |
Sets the command that will be executed by the built command node. More... | |
Command< S > | getCommand () |
Returns the Command the built command node will execute. More... | |
T | requires (final Predicate< S > requirement) |
Sets the predicate that must be true for a command source in order to be able to use the built command node or its children. More... | |
Predicate< S > | getRequirement () |
Returns the requirement each command source must meet in order to be able to use this command node. More... | |
T | redirect (final CommandNode< S > target) |
Redirects this command node to the target CommandNode . More... | |
T | redirect (final CommandNode< S > target, final SingleRedirectModifier< S > modifier) |
Redirects this command node to the target CommandNode . More... | |
T | fork (final CommandNode< S > target, final RedirectModifier< S > modifier) |
Forks this command node, i.e. More... | |
T | forward (final CommandNode< S > target, final RedirectModifier< S > modifier, final boolean fork) |
Forwards this command in some way to a given target command. More... | |
CommandNode< S > | getRedirect () |
Returns the command node that the built command node redirects to. More... | |
RedirectModifier< S > | getRedirectModifier () |
Returns the redirect modifier for the built command node. More... | |
boolean | isFork () |
Returns whether the built command node forks. More... | |
Static Public Member Functions | |
static< S, T > RequiredArgumentBuilder< S, T > | argument (final String name, final ArgumentType< T > type) |
A factory method to create a new builder for an argument command node. More... | |
Protected Member Functions | |
RequiredArgumentBuilder< S, T > | getThis () |
An ArgumentBuilder
for a ArgumentCommandNode
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 node will use |
|
static |
A factory method to create a new builder for an argument command node.
This method is intended for static importing, so you can just use "argument(<name>, <type>)"
in your code.
name | the name of the argument. Used with CommandContext#getArgument to retrieve the parsed argument out of a CommandContext |
type | the ArgumentType this command builder takes |
<S> | the type of the command source |
<T> | the type of the argument this command builder takes |
|
inherited |
Sets the command that will be executed by the built command node.
command | the Command to execute |
|
inherited |
Forks this command node, i.e.
it splits execution and calls the target command node multiple times with different sources.
Forking means that the target command will be invoked multiple times, once for each source in the list of sources generated by the passed RedirectModifier
.
target | the command node that will be invoked when the built command node is executed |
modifier | the redirect modifier to use to generate the command source list |
|
inherited |
Forwards this command in some way to a given target command.
It will call the target
command node for each command source in the list the modifier
returns, but the semantics differ slightly. Please have a look at CommandDispatcher#execute(ParseResults)
for a more detailed explanation.
target | the command node that will be invoked when the built command node is executed |
modifier | the redirect modifier to use to generate the command source list |
fork | whether the command node should be forked |
|
inherited |
Returns all registered child command nodes.
|
inherited |
String com.mojang.brigadier.builder.RequiredArgumentBuilder< S, T >.getName | ( | ) |
Returns the name of the argument the built command node will have.
Can be used with CommandContext#getArgument
to retrieve the parsed argument
|
inherited |
Returns the command node that the built command node redirects to.
|
inherited |
Returns the redirect modifier for the built command node.
|
inherited |
Returns the requirement each command source must meet in order to be able to use this command node.
SuggestionProvider< S > com.mojang.brigadier.builder.RequiredArgumentBuilder< S, T >.getSuggestionsProvider | ( | ) |
Returns the SuggestionProvider
the command node uses to advice the user on possible completions.
SuggestionProvider
or null if not set ArgumentType< T > com.mojang.brigadier.builder.RequiredArgumentBuilder< S, T >.getType | ( | ) |
Returns the ArgumentType
the built command node will use.
ArgumentType
the built command node will use
|
inherited |
Returns whether the built command node forks.
|
inherited |
Redirects this command node to the target CommandNode
.
A redirected node will appear in usage listings, but will otherwise behave just like an alias to the command node it points to.
This method sets isFork()
to false and applies no RedirectModifier
.
target | the command node that will be invoked when the built command node is executed |
|
inherited |
Redirects this command node to the target CommandNode
.
A redirected node will appear in usage listings, but will otherwise behave just like an alias to the command node it points to.
This method sets isFork()
to false and applies the given SingleRedirectModifier
.
target | the command node that will be invoked when the built command node is executed |
modifier | the redirect modifier to apply |
|
inherited |
Sets the predicate that must be true for a command source in order to be able to use the built command node or its children.
The default requirement, if you set none, is always true.
requirement | the requirement each command source needs to fulfill in order to be able to use the built command node or its children |
RequiredArgumentBuilder< S, T > com.mojang.brigadier.builder.RequiredArgumentBuilder< S, T >.suggests | ( | final SuggestionProvider< S > | provider | ) |
Sets the SuggestionProvider
that provides the user with suggestions about what the next value could be.
provider | the SuggestionProvider to use |
|
inherited |
Builds the given ArgumentBuilder and adds the result as new child node.
argument | the ArgumentBuilder to add |
IllegalStateException | if getRedirect() is set (i.e. not null) |
|
inherited |
Adds the given command node as a child.
argument | the command node to add |
IllegalStateException | if getRedirect() is set (i.e. not null) |