CommandAPI 9.6.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender > Class Template Referenceabstract

A builder used to create commands to be registered by the CommandAPI. More...

+ Inheritance diagram for dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >:

Public Member Functions

Impl withArguments (List< Argument > args)
 Appends the arguments to the current command builder. More...
 
final Impl withArguments (Argument... args)
 Appends the argument(s) to the current command builder. More...
 
Impl withOptionalArguments (List< Argument > args)
 Appends the optional arguments to the current command builder. More...
 
final Impl withOptionalArguments (Argument... args)
 Appends the optional arguments to the current command builder. More...
 
Impl withSubcommand (Impl subcommand)
 Adds a subcommand to this command builder. More...
 
Impl withSubcommands (@SuppressWarnings("unchecked") Impl... subcommands)
 Adds subcommands to this command builder. More...
 
List< ArgumentgetArguments ()
 Returns the list of arguments that this command has. More...
 
void setArguments (List< Argument > args)
 Sets the arguments that this command has. More...
 
List< Impl > getSubcommands ()
 Returns the list of subcommands that this command has. More...
 
void setSubcommands (List< Impl > subcommands)
 Sets the list of subcommands that this command has. More...
 
boolean isConverted ()
 Returns whether this command is an automatically converted command. More...
 
void register (String namespace)
 Registers the command with a given namespace. More...
 
Impl copy ()
 
String getName ()
 Returns the name of this command. More...
 
Impl withPermission (CommandPermission permission)
 Applies a permission to the current command builder. More...
 
Impl withPermission (String permission)
 Applies a permission to the current command builder. More...
 
Impl withoutPermission (CommandPermission permission)
 Applies a permission to the current command builder. More...
 
Impl withoutPermission (String permission)
 Applies a permission to the current command builder. More...
 
Impl withRequirement (Predicate< CommandSender > requirement)
 Adds a requirement that has to be satisfied to use this command. More...
 
Impl withAliases (String... aliases)
 Adds an array of aliases to the current command builder. More...
 
CommandPermission getPermission ()
 Returns the permission associated with this command. More...
 
void setPermission (CommandPermission permission)
 Sets the permission required to run this command. More...
 
String[] getAliases ()
 Returns an array of aliases that can be used to run this command. More...
 
void setAliases (String[] aliases)
 Sets the aliases for this command. More...
 
Predicate< CommandSender > getRequirements ()
 Returns the requirements that must be satisfied to run this command. More...
 
void setRequirements (Predicate< CommandSender > requirements)
 Sets the requirements that must be satisfied to run this command. More...
 
String getShortDescription ()
 Returns the short description for this command. More...
 
Impl withShortDescription (String description)
 Sets the short description for this command. More...
 
String getFullDescription ()
 Returns the full description for this command. More...
 
Impl withFullDescription (String description)
 Sets the full description for this command. More...
 
Impl withUsage (String... usage)
 Sets the full usage for this command. More...
 
String[] getUsage ()
 Returns the usage for this command. More...
 
Impl withHelp (String shortDescription, String fullDescription)
 Sets the short and full description for this command. More...
 
void override ()
 Overrides a command. More...
 
void register ()
 Registers this command with the default namespace.
 
CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > > getExecutor ()
 Returns the executors that this command has. More...
 
void setExecutor (CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > > executor)
 Sets the executors for this command. More...
 
Impl clearExecutors ()
 Clear all executors from the current command builder. More...
 
Impl instance ()
 Returns the instance of this class with the class Impl. More...
 

Protected Member Functions

 AbstractCommandAPICommand (String commandName)
 Creates a new command builder. More...
 
 AbstractCommandAPICommand (CommandMetaData< CommandSender > metaData)
 Creates a new Command builder. More...
 
abstract Impl newConcreteCommandAPICommand (CommandMetaData< CommandSender > metaData)
 

Protected Attributes

List< Argumentarguments = new ArrayList<>()
 
List< Impl > subcommands = new ArrayList<>()
 
boolean isConverted
 
final CommandMetaData< CommandSender > meta
 The Command's meta-data for this executable command.
 
CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > > executor = new CommandAPIExecutor<>()
 The CommandAPIExecutor for this executable implementation.
 

Detailed Description

A builder used to create commands to be registered by the CommandAPI.

Parameters
<Impl>The class extending this class, used as the return type for chain calls
<Argument>The implementation of AbstractArgument used by the class extending this class
<CommandSender>The CommandSender class used by the class extending this class

Constructor & Destructor Documentation

◆ AbstractCommandAPICommand() [1/2]

dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.AbstractCommandAPICommand ( String  commandName)
protected

Creates a new command builder.

Parameters
commandNameThe name of the command to create

◆ AbstractCommandAPICommand() [2/2]

dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.AbstractCommandAPICommand ( CommandMetaData< CommandSender >  metaData)
protected

Creates a new Command builder.

Parameters
metaDataThe metadata of the command to create

Member Function Documentation

◆ clearExecutors()

Impl dev.jorel.commandapi.Executable< Impl, CommandSender >.clearExecutors ( )
inherited

Clear all executors from the current command builder.

Returns
this command builder

◆ getAliases()

String[] dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getAliases ( )
inherited

Returns an array of aliases that can be used to run this command.

Returns
an array of aliases that can be used to run this command

◆ getArguments()

List< Argument > dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.getArguments ( )

Returns the list of arguments that this command has.

Returns
the list of arguments that this command has

◆ getExecutor()

CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > > dev.jorel.commandapi.Executable< Impl, CommandSender >.getExecutor ( )
inherited

Returns the executors that this command has.

Returns
the executors that this command has

◆ getFullDescription()

String dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getFullDescription ( )
inherited

Returns the full description for this command.

Returns
the full description for this command

◆ getName()

String dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getName ( )
inherited

Returns the name of this command.

Returns
the name of this command

◆ getPermission()

CommandPermission dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getPermission ( )
inherited

Returns the permission associated with this command.

Returns
the permission associated with this command

◆ getRequirements()

Predicate< CommandSender > dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getRequirements ( )
inherited

Returns the requirements that must be satisfied to run this command.

Returns
the requirements that must be satisfied to run this command

◆ getShortDescription()

String dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getShortDescription ( )
inherited

Returns the short description for this command.

Returns
the short description for this command

◆ getSubcommands()

List< Impl > dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.getSubcommands ( )

Returns the list of subcommands that this command has.

Returns
the list of subcommands that this command has

◆ getUsage()

String[] dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.getUsage ( )
inherited

Returns the usage for this command.

Returns
the usage for this command

◆ instance()

Impl dev.jorel.commandapi.ChainableBuilder< Impl >.instance ( )
inherited

Returns the instance of this class with the class Impl.

Used for chaining builder methods.

Implemented in dev.jorel.commandapi.arguments.Argument< T >.

◆ isConverted()

boolean dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.isConverted ( )

Returns whether this command is an automatically converted command.

Returns
whether this command is an automatically converted command

◆ override()

void dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.override ( )
inherited

Overrides a command.

Effectively the same as unregistering the command using CommandAPI.unregister() and then registering the command using .register()

◆ register()

void dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.register ( String  namespace)

Registers the command with a given namespace.

Parameters
namespaceThe namespace of this command. This cannot be null
Exceptions
NullPointerExceptionif the namespace is null

Reimplemented from dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.

◆ setAliases()

void dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.setAliases ( String[]  aliases)
inherited

Sets the aliases for this command.

Parameters
aliasesthe aliases for this command

◆ setArguments()

void dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.setArguments ( List< Argument args)

Sets the arguments that this command has.

Parameters
argsthe arguments that this command has

◆ setExecutor()

void dev.jorel.commandapi.Executable< Impl, CommandSender >.setExecutor ( CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > >  executor)
inherited

Sets the executors for this command.

Parameters
executorthe executors for this command

◆ setPermission()

void dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.setPermission ( CommandPermission  permission)
inherited

Sets the permission required to run this command.

Parameters
permissionthe permission required to run this command

◆ setRequirements()

void dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.setRequirements ( Predicate< CommandSender >  requirements)
inherited

Sets the requirements that must be satisfied to run this command.

Parameters
requirementsthe requirements that must be satisfied to run this command

◆ setSubcommands()

void dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.setSubcommands ( List< Impl >  subcommands)

Sets the list of subcommands that this command has.

Parameters
subcommandsthe list of subcommands that this command has

◆ withAliases()

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withAliases ( String...  aliases)
inherited

Adds an array of aliases to the current command builder.

Parameters
aliasesAn array of aliases which can be used to execute this command
Returns
this command builder

◆ withArguments() [1/2]

final Impl dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.withArguments ( Argument...  args)

Appends the argument(s) to the current command builder.

Parameters
argsArguments that this command can accept
Returns
this command builder

◆ withArguments() [2/2]

Impl dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.withArguments ( List< Argument args)

Appends the arguments to the current command builder.

Parameters
argsA List that represents the arguments that this command can accept
Returns
this command builder

◆ withFullDescription()

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withFullDescription ( String  description)
inherited

Sets the full description for this command.

This is the help which is shown in the specific /help page for this command (e.g. /help mycommand).

Parameters
descriptionthe full description for this command
Returns
this command builder

◆ withHelp()

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withHelp ( String  shortDescription,
String  fullDescription 
)
inherited

Sets the short and full description for this command.

This is a short-hand for the ExecutableCommand#withShortDescription and ExecutableCommand#withFullDescription methods.

Parameters
shortDescriptionthe short description for this command
fullDescriptionthe full description for this command
Returns
this command builder

◆ withOptionalArguments() [1/2]

final Impl dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.withOptionalArguments ( Argument...  args)

Appends the optional arguments to the current command builder.

This also calls AbstractArgument#setOptional(boolean) on each argument to make sure they are optional

Parameters
argsArguments that this command can accept
Returns
this command builder

◆ withOptionalArguments() [2/2]

Impl dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.withOptionalArguments ( List< Argument args)

Appends the optional arguments to the current command builder.

This also calls AbstractArgument#setOptional(boolean) on each argument to make sure they are optional

Parameters
argsA List that represents the arguments that this command can accept
Returns
this command builder

◆ withoutPermission() [1/2]

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withoutPermission ( CommandPermission  permission)
inherited

Applies a permission to the current command builder.

Parameters
permissionThe permission node required to execute this command
Returns
this command builder

◆ withoutPermission() [2/2]

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withoutPermission ( String  permission)
inherited

Applies a permission to the current command builder.

Parameters
permissionThe permission node required to execute this command
Returns
this command builder

◆ withPermission() [1/2]

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withPermission ( CommandPermission  permission)
inherited

Applies a permission to the current command builder.

Parameters
permissionThe permission node required to execute this command
Returns
this command builder

◆ withPermission() [2/2]

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withPermission ( String  permission)
inherited

Applies a permission to the current command builder.

Parameters
permissionThe permission node required to execute this command
Returns
this command builder

◆ withRequirement()

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withRequirement ( Predicate< CommandSender >  requirement)
inherited

Adds a requirement that has to be satisfied to use this command.

This method can be used multiple times and each use of this method will AND its requirement with the previously declared ones

Parameters
requirementthe predicate that must be satisfied to use this command
Returns
this command builder

◆ withShortDescription()

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withShortDescription ( String  description)
inherited

Sets the short description for this command.

This is the help which is shown in the main /help menu.

Parameters
descriptionthe short description for this command
Returns
this command builder

◆ withSubcommand()

Impl dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.withSubcommand ( Impl  subcommand)

Adds a subcommand to this command builder.

Parameters
subcommandthe subcommand to add as a child of this command
Returns
this command builder

◆ withSubcommands()

Impl dev.jorel.commandapi.AbstractCommandAPICommand< Impl, Argument, CommandSender >.withSubcommands ( @SuppressWarnings("unchecked") Impl...  subcommands)

Adds subcommands to this command builder.

Parameters
subcommandsthe subcommands to add as children of this command
Returns
this command builder

◆ withUsage()

Impl dev.jorel.commandapi.ExecutableCommand< Impl, CommandSender >.withUsage ( String...  usage)
inherited

Sets the full usage for this command.

This is the usage which is shown in the specific /help page for this command (e.g. /help mycommand).

Parameters
usagethe full usage for this command
Returns
this command builder