Package dev.jorel.commandapi
Class CommandAPICommand
java.lang.Object
dev.jorel.commandapi.CommandAPICommand
A builder used to create commands to be registered by the CommandAPI.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CustomCommandExecutor<?>The CustomCommandExecutor for this executable implementationprotected final dev.jorel.commandapi.CommandMetaDataThe Command's meta data for this executable command -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCommandAPICommand(dev.jorel.commandapi.CommandMetaData metaData) Creates a new Command builderCommandAPICommand(String commandName) Creates a new command builder -
Method Summary
Modifier and TypeMethodDescriptionClear all executors from the current command builderexecutes(CommandExecutor executor, ExecutorType... types) Adds an executor to the current command builderexecutes(ResultingCommandExecutor executor, ExecutorType... types) Adds an executor to the current command builderAdds an executor to the current command builderAdds an executor to the current command builderexecutesConsole(ConsoleCommandExecutor executor) Adds an executor to the current command builderAdds an executor to the current command builderexecutesEntity(EntityCommandExecutor executor) Adds an executor to the current command builderexecutesEntity(EntityResultingCommandExecutor executor) Adds an executor to the current command builderexecutesNative(NativeCommandExecutor executor) Adds an executor to the current command builderexecutesNative(NativeResultingCommandExecutor executor) Adds an executor to the current command builderexecutesPlayer(PlayerCommandExecutor executor) Adds an executor to the current command builderexecutesPlayer(PlayerResultingCommandExecutor executor) Adds an executor to the current command builderexecutesProxy(ProxyCommandExecutor executor) Adds an executor to the current command builderexecutesProxy(ProxyResultingCommandExecutor executor) Adds an executor to the current command builderString[]Returns an array of aliases that can be used to run this commandReturns the list of arguments that this command hasCustomCommandExecutor<? extends org.bukkit.command.CommandSender>Returns the executors that this command hasgetName()Returns the name of this commandReturns the permission associated with this commandPredicate<org.bukkit.command.CommandSender>Returns the requirements that must be satisfied to run this commandReturns the list of subcommands that this command hasbooleanReturns whether this command is an automatically converted commandvoidoverride()Overrides a command.voidregister()Registers this commandvoidsetAliases(String[] aliases) Sets the aliases for this commandvoidsetArguments(List<Argument<?>> args) Sets the arguments that this command hasvoidsetExecutor(CustomCommandExecutor<? extends org.bukkit.command.CommandSender> executor) Sets the executors for this commandvoidsetPermission(CommandPermission permission) Sets the permission required to run this commandvoidsetRequirements(Predicate<org.bukkit.command.CommandSender> requirements) Sets the requirements that must be satisfied to run this commandvoidsetSubcommands(List<CommandAPICommand> subcommands) Sets the list of subcommands that this command haswithAliases(String... aliases) Adds an array of aliases to the current command builderwithArguments(Argument<?>... args) Appends the argument(s) to the current command builderwithArguments(List<Argument<?>> args) Appends the arguments to the current command builderwithFullDescription(String description) Sets the full description for this command.Sets the short and full description for this command.withoutPermission(CommandPermission permission) Applies a permission to the current command builderwithoutPermission(String permission) Applies a permission to the current command builderwithPermission(CommandPermission permission) Applies a permission to the current command builderwithPermission(String permission) Applies a permission to the current command builderwithRequirement(Predicate<org.bukkit.command.CommandSender> requirement) Adds a requirement that has to be satisfied to use this command.withShortDescription(String description) Sets the short description for this command.withSubcommand(CommandAPICommand subcommand) Adds a subcommand to this command builderwithSubcommands(CommandAPICommand... subcommands) Adds subcommands to this command builder
-
Field Details
-
meta
protected final dev.jorel.commandapi.CommandMetaData metaThe Command's meta data for this executable command -
executor
The CustomCommandExecutor for this executable implementation
-
-
Constructor Details
-
CommandAPICommand
Creates a new command builder- Parameters:
commandName- The name of the command to create
-
CommandAPICommand
protected CommandAPICommand(dev.jorel.commandapi.CommandMetaData metaData) Creates a new Command builder- Parameters:
metaData- The metadata of the command to create
-
-
Method Details
-
withArguments
Appends the arguments to the current command builder- Parameters:
args- AListthat represents the arguments that this command can accept- Returns:
- this command builder
-
withArguments
Appends the argument(s) to the current command builder- Parameters:
args- Arguments that this command can accept- Returns:
- this command builder
-
withSubcommand
Adds a subcommand to this command builder- Parameters:
subcommand- the subcommand to add as a child of this command- Returns:
- this command builder
-
withSubcommands
Adds subcommands to this command builder- Parameters:
subcommands- the subcommands to add as children of this command- Returns:
- this command builder
-
getArguments
Returns the list of arguments that this command has- Returns:
- the list of arguments that this command has
-
setArguments
Sets the arguments that this command has- Parameters:
args- the arguments that this command has
-
getSubcommands
Returns the list of subcommands that this command has- Returns:
- the list of subcommands that this command has
-
setSubcommands
Sets the list of subcommands that this command has- Parameters:
subcommands- the list of subcommands that this command has
-
isConverted
public boolean isConverted()Returns whether this command is an automatically converted command- Returns:
- whether this command is an automatically converted command
-
register
public void register()Registers this command -
getName
Returns the name of this command- Returns:
- the name of this command
-
withPermission
Applies a permission to the current command builder- Parameters:
permission- The permission node required to execute this command- Returns:
- this command builder
-
withPermission
Applies a permission to the current command builder- Parameters:
permission- The permission node required to execute this command- Returns:
- this command builder
-
withoutPermission
Applies a permission to the current command builder- Parameters:
permission- The permission node required to execute this command- Returns:
- this command builder
-
withoutPermission
Applies a permission to the current command builder- Parameters:
permission- The permission node required to execute this command- Returns:
- this command builder
-
withRequirement
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:
requirement- the predicate that must be satisfied to use this command- Returns:
- this command builder
-
withAliases
Adds an array of aliases to the current command builder- Parameters:
aliases- An array of aliases which can be used to execute this command- Returns:
- this command builder
-
getPermission
Returns the permission associated with this command- Returns:
- the permission associated with this command
-
setPermission
Sets the permission required to run this command- Parameters:
permission- the permission required to run this command
-
getAliases
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
-
setAliases
Sets the aliases for this command- Parameters:
aliases- the aliases for this command
-
getRequirements
Returns the requirements that must be satisfied to run this command- Returns:
- the requirements that must be satisfied to run this command
-
setRequirements
Sets the requirements that must be satisfied to run this command- Parameters:
requirements- the requirements that must be satisfied to run this command
-
withShortDescription
Sets the short description for this command. This is the help which is shown in the main /help menu.- Parameters:
description- the short description for this command- Returns:
- this command builder
-
withFullDescription
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:
description- the full description for this command- Returns:
- this command builder
-
withHelp
Sets the short and full description for this command. This is a short-hand for theExecutableCommand.withShortDescription(java.lang.String)andExecutableCommand.withFullDescription(java.lang.String)methods.- Parameters:
shortDescription- the short description for this commandfullDescription- the full description for this command- Returns:
- this command builder
-
override
public void override()Overrides a command. Effectively the same as unregistering the command using CommandAPI.unregister() and then registering the command using .register() -
executes
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(CommandSender, Object[]) -> ()that will be executed when the command is runtypes- A list of executor types to use this executes method for.- Returns:
- this command builder
-
executes
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(CommandSender, Object[]) -> intthat will be executed when the command is runtypes- A list of executor types to use this executes method for.- Returns:
- this command builder
-
executesPlayer
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Player, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesPlayer
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Player, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesEntity
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesEntity
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesProxy
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesProxy
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesCommandBlock
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesCommandBlock
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesConsole
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesConsole
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesNative
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(NativeCommandExecutor, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesNative
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(NativeCommandExecutor, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
getExecutor
Returns the executors that this command has- Returns:
- the executors that this command has
-
setExecutor
Sets the executors for this command- Parameters:
executor- the executors for this command
-
clearExecutors
Clear all executors from the current command builder- Returns:
- this command builder
-