Package dev.jorel.commandapi
Class AbstractCommandAPICommand<Impl extends AbstractCommandAPICommand<Impl,Argument,CommandSender>,Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender>
java.lang.Object
dev.jorel.commandapi.AbstractCommandAPICommand<Impl,Argument,CommandSender>
- Type Parameters:
Impl- The class extending this class, used as the return type for chain callsArgument- The implementation of AbstractArgument used by the class extending this classCommandSender- The CommandSender class used by the class extending this class
- All Implemented Interfaces:
ChainableBuilder<Impl>
public abstract class AbstractCommandAPICommand<Impl extends AbstractCommandAPICommand<Impl,Argument,CommandSender>,Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender>
extends Object
A builder used to create commands to be registered by the CommandAPI.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CommandAPIExecutor<CommandSender,AbstractCommandSender<? extends CommandSender>> The CommandAPIExecutor for this executable implementationprotected booleanprotected final dev.jorel.commandapi.CommandMetaData<CommandSender>The Command's meta-data for this executable command -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> metaData) Creates a new Command builderprotectedAbstractCommandAPICommand(String commandName) Creates a new command builder -
Method Summary
Modifier and TypeMethodDescriptionClear all executors from the current command buildercopy()String[]Returns an array of aliases that can be used to run this commandReturns the list of arguments that this command hasReturns the executors that this command hasReturns the full description for this commandgetName()Returns the name of this commandReturns the permission associated with this commandReturns the requirements that must be satisfied to run this commandReturns the short description for this commandReturns the list of subcommands that this command hasString[]getUsage()Returns the usage for this commandbooleanReturns whether this command is an automatically converted commandprotected abstract ImplnewConcreteCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> metaData) voidoverride()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(CommandAPIExecutor<CommandSender, AbstractCommandSender<? extends CommandSender>> executor) Sets the executors for this commandvoidsetPermission(CommandPermission permission) Sets the permission required to run this commandvoidsetRequirements(Predicate<CommandSender> requirements) Sets the requirements that must be satisfied to run this commandvoidsetSubcommands(List<Impl> subcommands) Sets the list of subcommands that this command haswithAliases(String... aliases) Adds an array of aliases to the current command builderfinal ImplwithArguments(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.final ImplwithOptionalArguments(Argument... args) Appends the optional arguments to the current command builder.withOptionalArguments(List<Argument> args) Appends the optional arguments to the current command builder.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<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(Impl subcommand) Adds a subcommand to this command builderwithSubcommands(Impl... subcommands) Adds subcommands to this command builderSets the full usage for this command.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.jorel.commandapi.ChainableBuilder
instance
-
Field Details
-
arguments
-
subcommands
-
isConverted
protected boolean isConverted -
meta
The Command's meta-data for this executable command -
executor
The CommandAPIExecutor for this executable implementation
-
-
Constructor Details
-
AbstractCommandAPICommand
Creates a new command builder- Parameters:
commandName- The name of the command to create
-
AbstractCommandAPICommand
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
-
withOptionalArguments
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:
args- AListthat represents the arguments that this command can accept- Returns:
- this command builder
-
withOptionalArguments
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:
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 -
copy
-
newConcreteCommandAPICommand
protected abstract Impl newConcreteCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> metaData) -
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
-
getShortDescription
Returns the short description for this command- Returns:
- the short description for 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
-
getFullDescription
Returns the full description for this command- Returns:
- the full description for this command
-
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
-
withUsage
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:
usage- the full usage for this command- Returns:
- this command builder
-
getUsage
Returns the usage for this command- Returns:
- the usage for this command
-
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() -
getExecutor
public CommandAPIExecutor<CommandSender,AbstractCommandSender<? extends CommandSender>> getExecutor()Returns the executors that this command has- Returns:
- the executors that this command has
-
setExecutor
public void setExecutor(CommandAPIExecutor<CommandSender, AbstractCommandSender<? extends CommandSender>> executor) 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
-