java.lang.Object
org.teleight.teleightbots.commands.builder.Command

public abstract class Command extends Object
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 Details

    • Command

      public Command(@NotNull @NotNull String name)
      Constructs a command with the given name.
      Parameters:
      name - the name of the command
      Throws:
      NullPointerException - if the name is null
    • Command

      public Command(@NotNull @NotNull String name, @NotNull @NotNull String... aliases)
      Constructs a command with the given name and aliases.
      Parameters:
      name - the name of the command
      aliases - the aliases of the command
      Throws:
      NullPointerException - if the name or aliases are null
  • Method Details

    • getDefaultExecutor

      @Nullable public @Nullable CommandExecutor getDefaultExecutor()
      Returns the default executor for this command.
      Returns:
      the default executor, or null if none is set
    • setDefaultExecutor

      protected final void setDefaultExecutor(@NotNull @NotNull CommandExecutor executor)
      Sets the default executor for this command.
      Parameters:
      executor - the executor to set as the default
      Throws:
      NullPointerException - if the executor is null
    • getCondition

      @Nullable public @Nullable CommandCondition getCondition()
      Returns the condition for this command.
      Returns:
      the condition, or null if none is set
    • setCondition

      protected void setCondition(@Nullable @Nullable CommandCondition commandCondition)
      Sets the condition for this command.
      Parameters:
      commandCondition - the condition to set
    • getName

      @NotNull public @NotNull String getName()
      Returns the name of this command.
      Returns:
      the name of the command
    • getAliases

      @NotNull public @NotNull String[] 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 syntax
      args - 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 syntax
      executor - the executor for the syntax
      args - the arguments for the syntax
      Throws:
      NullPointerException - if the condition, executor, or args are null
    • getSyntaxes

      public List<CommandSyntax> getSyntaxes()
      Returns the list of syntaxes for this command.
      Returns:
      the list of syntaxes