CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
com.mojang.brigadier.builder.LiteralArgumentBuilder< S > Class Template Reference

An ArgumentBuilder for a LiteralCommandNode that is triggered by a literal (i.e. More...

+ Inheritance diagram for com.mojang.brigadier.builder.LiteralArgumentBuilder< S >:

Public Member Functions

String getLiteral ()
 Returns the literal that the built command node will be identified by. More...
 
LiteralCommandNode< S > build ()
 
then (final ArgumentBuilder< S, ?> argument)
 Builds the given ArgumentBuilder and adds the result as new child node. More...
 
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...
 
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...
 
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...
 
redirect (final CommandNode< S > target)
 Redirects this command node to the target CommandNode. More...
 
redirect (final CommandNode< S > target, final SingleRedirectModifier< S > modifier)
 Redirects this command node to the target CommandNode. More...
 
fork (final CommandNode< S > target, final RedirectModifier< S > modifier)
 Forks this command node, i.e. More...
 
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 > LiteralArgumentBuilder< S > literal (final String name)
 A factory method to create a new builder for a literal command node. More...
 

Protected Member Functions

 LiteralArgumentBuilder (final String literal)
 Creates a new LiteralArgumentBuilder with the given literal. More...
 
LiteralArgumentBuilder< S > getThis ()
 

Detailed Description

An ArgumentBuilder for a LiteralCommandNode that is triggered by a literal (i.e.

fixed) keyword.

An example would be a command like "ping", that is identified by its keyword.

Parameters
<S>the type of the command source

Constructor & Destructor Documentation

◆ LiteralArgumentBuilder()

Creates a new LiteralArgumentBuilder with the given literal.

Parameters
literalthe literal that identifies the built command node

Member Function Documentation

◆ executes()

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.executes ( final Command< S >  command)
inherited

Sets the command that will be executed by the built command node.

Parameters
commandthe Command to execute
Returns
this object

◆ fork()

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.fork ( final CommandNode< S >  target,
final RedirectModifier< S >  modifier 
)
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.

Parameters
targetthe command node that will be invoked when the built command node is executed
modifierthe redirect modifier to use to generate the command source list
Returns
this object
See also
forward

◆ forward()

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.forward ( final CommandNode< S >  target,
final RedirectModifier< S >  modifier,
final boolean  fork 
)
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.

Parameters
targetthe command node that will be invoked when the built command node is executed
modifierthe redirect modifier to use to generate the command source list
forkwhether the command node should be forked
Returns
this object
See also
CommandDispatcher::execute(ParseResults)

◆ getArguments()

Collection< CommandNode< S > > com.mojang.brigadier.builder.ArgumentBuilder< S, T >.getArguments ( )
inherited

Returns all registered child command nodes.

Returns
all registered child command nodes

◆ getCommand()

Command< S > com.mojang.brigadier.builder.ArgumentBuilder< S, T >.getCommand ( )
inherited

Returns the Command the built command node will execute.

Returns
the Command the built command node will execute or null if not set

◆ getLiteral()

Returns the literal that the built command node will be identified by.

Returns
the literal that the built command node will be identified by

◆ getRedirect()

CommandNode< S > com.mojang.brigadier.builder.ArgumentBuilder< S, T >.getRedirect ( )
inherited

Returns the command node that the built command node redirects to.

Returns
the command node that the built command node redirects to or null if not set

◆ getRedirectModifier()

RedirectModifier< S > com.mojang.brigadier.builder.ArgumentBuilder< S, T >.getRedirectModifier ( )
inherited

Returns the redirect modifier for the built command node.

Returns
the redirect modifier for the built command node or null if none

◆ getRequirement()

Predicate< S > com.mojang.brigadier.builder.ArgumentBuilder< S, T >.getRequirement ( )
inherited

Returns the requirement each command source must meet in order to be able to use this command node.

Returns
the requirement each command source must meet in order to be able to use this command node

◆ isFork()

boolean com.mojang.brigadier.builder.ArgumentBuilder< S, T >.isFork ( )
inherited

Returns whether the built command node forks.

Returns
true if the built command node forks

◆ literal()

static< S > LiteralArgumentBuilder< S > com.mojang.brigadier.builder.LiteralArgumentBuilder< S >.literal ( final String  name)
static

A factory method to create a new builder for a literal command node.

Parameters
namethe literal the built command node should be identified by
<S>the type of the command source
Returns
the created LiteralArgumentBuilder

◆ redirect() [1/2]

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.redirect ( final CommandNode< S >  target)
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.

Parameters
targetthe command node that will be invoked when the built command node is executed
Returns
this object
See also
forward

◆ redirect() [2/2]

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.redirect ( final CommandNode< S >  target,
final SingleRedirectModifier< S >  modifier 
)
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.

Parameters
targetthe command node that will be invoked when the built command node is executed
modifierthe redirect modifier to apply
Returns
this object
See also
forward

◆ requires()

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.requires ( final Predicate< S >  requirement)
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.

Parameters
requirementthe requirement each command source needs to fulfill in order to be able to use the built command node or its children
Returns
this object

◆ then() [1/2]

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.then ( final ArgumentBuilder< S, ?>  argument)
inherited

Builds the given ArgumentBuilder and adds the result as new child node.

Parameters
argumentthe ArgumentBuilder to add
Returns
this object
Exceptions
IllegalStateExceptionif getRedirect() is set (i.e. not null)
See also
#then(CommandNode)

◆ then() [2/2]

T com.mojang.brigadier.builder.ArgumentBuilder< S, T >.then ( final CommandNode< S >  argument)
inherited

Adds the given command node as a child.

Parameters
argumentthe command node to add
Returns
this object
Exceptions
IllegalStateExceptionif getRedirect() is set (i.e. not null)