Class Command
java.lang.Object
org.teleight.teleightbots.commands.builder.Command
Represents a command with a name, aliases, and a set of syntaxes.
Commands can have a default executor and a condition to be checked before execution.
This abstract class serves as a base for creating specific commands.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConditionalSyntax(@NotNull CommandCondition condition, @NotNull CommandExecutor executor, @NotNull Argument<?>... args) Adds a conditional syntax to this command with the given condition, executor, and arguments.voidaddSyntax(@NotNull CommandExecutor executor, @NotNull Argument<?>... args) Adds a syntax to this command with the given executor and arguments.@NotNull String[]Returns the aliases of this command.@Nullable CommandConditionReturns the condition for this command.@Nullable CommandExecutorReturns the default executor for this command.@NotNull StringgetName()Returns the name of this command.Returns the list of syntaxes for this command.protected voidsetCondition(@Nullable CommandCondition commandCondition) Sets the condition for this command.protected final voidsetDefaultExecutor(@NotNull CommandExecutor executor) Sets the default executor for this command.
-
Constructor Details
-
Command
Constructs a command with the given name.- Parameters:
name- the name of the command- Throws:
NullPointerException- if the name is null
-
Command
Constructs a command with the given name and aliases.- Parameters:
name- the name of the commandaliases- the aliases of the command- Throws:
NullPointerException- if the name or aliases are null
-
-
Method Details
-
getDefaultExecutor
Returns the default executor for this command.- Returns:
- the default executor, or null if none is set
-
setDefaultExecutor
Sets the default executor for this command.- Parameters:
executor- the executor to set as the default- Throws:
NullPointerException- if the executor is null
-
getCondition
Returns the condition for this command.- Returns:
- the condition, or null if none is set
-
setCondition
Sets the condition for this command.- Parameters:
commandCondition- the condition to set
-
getName
Returns the name of this command.- Returns:
- the name of the command
-
getAliases
Returns the aliases of this command.- Returns:
- an array of aliases
-
addSyntax
public void addSyntax(@NotNull @NotNull CommandExecutor executor, @NotNull @NotNull Argument<?>... args) Adds a syntax to this command with the given executor and arguments.- Parameters:
executor- the executor for the syntaxargs- the arguments for the syntax- Throws:
NullPointerException- if the executor or args are null
-
addConditionalSyntax
public void addConditionalSyntax(@NotNull @NotNull CommandCondition condition, @NotNull @NotNull CommandExecutor executor, @NotNull @NotNull Argument<?>... args) Adds a conditional syntax to this command with the given condition, executor, and arguments.- Parameters:
condition- the condition for the syntaxexecutor- the executor for the syntaxargs- the arguments for the syntax- Throws:
NullPointerException- if the condition, executor, or args are null
-
getSyntaxes
Returns the list of syntaxes for this command.- Returns:
- the list of syntaxes
-