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 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 Object
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()
      Registers this command
    • copy

      public Impl copy()
    • newConcreteCommandAPICommand

      protected abstract Impl newConcreteCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> metaData)
    • getName

      public String getName()
      Returns the name of this command
      Returns:
      the name of this command
    • withPermission

      public Impl withPermission(CommandPermission permission)
      Applies a permission to the current command builder
      Parameters:
      permission - The permission node required to execute this command
      Returns:
      this command builder
    • withPermission

      public Impl withPermission(String permission)
      Applies a permission to the current command builder
      Parameters:
      permission - The permission node required to execute this command
      Returns:
      this command builder
    • withoutPermission

      public Impl withoutPermission(CommandPermission permission)
      Applies a permission to the current command builder
      Parameters:
      permission - The permission node required to execute this command
      Returns:
      this command builder
    • withoutPermission

      public Impl withoutPermission(String permission)
      Applies a permission to the current command builder
      Parameters:
      permission - The permission node required to execute this command
      Returns:
      this command builder
    • withRequirement

      public Impl withRequirement(Predicate<CommandSender> requirement)
      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

      public Impl withAliases(String... aliases)
      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

      public CommandPermission getPermission()
      Returns the permission associated with this command
      Returns:
      the permission associated with this command
    • setPermission

      public void setPermission(CommandPermission permission)
      Sets the permission required to run this command
      Parameters:
      permission - the permission required to run this command
    • getAliases

      public String[] 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

      public void setAliases(String[] aliases)
      Sets the aliases for this command
      Parameters:
      aliases - the aliases for this command
    • getRequirements

      public Predicate<CommandSender> getRequirements()
      Returns the requirements that must be satisfied to run this command
      Returns:
      the requirements that must be satisfied to run this command
    • setRequirements

      public void setRequirements(Predicate<CommandSender> requirements)
      Sets the requirements that must be satisfied to run this command
      Parameters:
      requirements - the requirements that must be satisfied to run this command
    • getShortDescription

      public String getShortDescription()
      Returns the short description for this command
      Returns:
      the short description for this command
    • withShortDescription

      public Impl withShortDescription(String description)
      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

      public String getFullDescription()
      Returns the full description for this command
      Returns:
      the full description for this command
    • withFullDescription

      public Impl withFullDescription(String description)
      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

      public Impl withUsage(String... usage)
      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

      public String[] getUsage()
      Returns the usage for this command
      Returns:
      the usage for this command
    • withHelp

      public Impl withHelp(String shortDescription, String fullDescription)
      Sets the short and full description for this command. This is a short-hand for the ExecutableCommand.withShortDescription(java.lang.String) and ExecutableCommand.withFullDescription(java.lang.String) methods.
      Parameters:
      shortDescription - the short description for this command
      fullDescription - 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

      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