Class AbstractCommandAPICommand<Impl extends AbstractCommandAPICommand<Impl,Argument,CommandSender>,Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender>

java.lang.Object
dev.jorel.commandapi.ExecutableCommand<Impl,CommandSender>
dev.jorel.commandapi.AbstractCommandAPICommand<Impl,Argument,CommandSender>
Type 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
All Implemented Interfaces:
ChainableBuilder<Impl>

public abstract class AbstractCommandAPICommand<Impl extends AbstractCommandAPICommand<Impl,Argument,CommandSender>,Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender> extends ExecutableCommand<Impl,CommandSender>
A builder used to create commands to be registered by the CommandAPI.
  • Field Details

  • Constructor Details

    • AbstractCommandAPICommand

      protected AbstractCommandAPICommand(String commandName)
      Creates a new command builder
      Parameters:
      commandName - The name of the command to create
    • AbstractCommandAPICommand

      protected AbstractCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> metaData)
      Creates a new Command builder
      Parameters:
      metaData - The metadata of the command to create
  • Method Details

    • withArguments

      public Impl withArguments(List<Argument> args)
      Appends the arguments to the current command builder
      Parameters:
      args - A List that represents the arguments that this command can accept
      Returns:
      this command builder
    • withArguments

      @SafeVarargs public final Impl withArguments(Argument... args)
      Appends the argument(s) to the current command builder
      Parameters:
      args - Arguments that this command can accept
      Returns:
      this command builder
    • withOptionalArguments

      public Impl 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:
      args - A List that represents the arguments that this command can accept
      Returns:
      this command builder
    • withOptionalArguments

      @SafeVarargs public final Impl 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:
      args - Arguments that this command can accept
      Returns:
      this command builder
    • withSubcommand

      public Impl withSubcommand(Impl subcommand)
      Adds a subcommand to this command builder
      Parameters:
      subcommand - the subcommand to add as a child of this command
      Returns:
      this command builder
    • withSubcommands

      public Impl withSubcommands(Impl... subcommands)
      Adds subcommands to this command builder
      Parameters:
      subcommands - the subcommands to add as children of this command
      Returns:
      this command builder
    • getArguments

      public List<Argument> getArguments()
      Returns the list of arguments that this command has
      Returns:
      the list of arguments that this command has
    • setArguments

      public void setArguments(List<Argument> args)
      Sets the arguments that this command has
      Parameters:
      args - the arguments that this command has
    • getSubcommands

      public List<Impl> getSubcommands()
      Returns the list of subcommands that this command has
      Returns:
      the list of subcommands that this command has
    • setSubcommands

      public void setSubcommands(List<Impl> subcommands)
      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()
      Description copied from class: ExecutableCommand
      Registers this command
      Specified by:
      register in class ExecutableCommand<Impl extends AbstractCommandAPICommand<Impl,Argument,CommandSender>,CommandSender>
    • copy

      public Impl copy()
    • newConcreteCommandAPICommand

      protected abstract Impl newConcreteCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> metaData)
    • 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

      public Impl clearExecutors()
      Clear all executors from the current command builder
      Returns:
      this command builder