Class CommandTree

java.lang.Object
dev.jorel.commandapi.CommandTree

public class CommandTree extends Object
This is the root node for creating a command as a tree
  • Field Details

    • meta

      protected final dev.jorel.commandapi.CommandMetaData meta
      The Command's meta data for this executable command
    • executor

      protected CustomCommandExecutor<?> executor
      The CustomCommandExecutor for this executable implementation
  • Constructor Details

    • CommandTree

      public CommandTree(String commandName)
      Creates a main root node for a command tree with a given command name
      Parameters:
      commandName - The name of the command to create
  • Method Details

    • then

      public CommandTree then(ArgumentTree tree)
      Create a child branch on the tree
      Parameters:
      tree - the child node
      Returns:
      this root node
    • register

      public void register()
      Registers the command
    • getName

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

      public CommandTree 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 CommandTree 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 CommandTree 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 CommandTree 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 CommandTree withRequirement(Predicate<org.bukkit.command.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 CommandTree 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<org.bukkit.command.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<org.bukkit.command.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
    • withShortDescription

      public CommandTree 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
    • withFullDescription

      public CommandTree 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
    • withHelp

      public CommandTree 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()
    • executes

      public CommandTree executes(CommandExecutor executor, ExecutorType... types)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (CommandSender, Object[]) -> () that will be executed when the command is run
      types - A list of executor types to use this executes method for.
      Returns:
      this command builder
    • executes

      public CommandTree executes(ResultingCommandExecutor executor, ExecutorType... types)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (CommandSender, Object[]) -> int that will be executed when the command is run
      types - A list of executor types to use this executes method for.
      Returns:
      this command builder
    • executesPlayer

      public CommandTree executesPlayer(PlayerCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Player, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesPlayer

      public CommandTree executesPlayer(PlayerResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Player, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesEntity

      public CommandTree executesEntity(EntityCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesEntity

      public CommandTree executesEntity(EntityResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesProxy

      public CommandTree executesProxy(ProxyCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesProxy

      public CommandTree executesProxy(ProxyResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesCommandBlock

      public CommandTree executesCommandBlock(CommandBlockCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesCommandBlock

      public CommandTree executesCommandBlock(CommandBlockResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesConsole

      public CommandTree executesConsole(ConsoleCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesConsole

      public CommandTree executesConsole(ConsoleResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesNative

      public CommandTree executesNative(NativeCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (NativeCommandExecutor, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesNative

      public CommandTree executesNative(NativeResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (NativeCommandExecutor, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • getExecutor

      public CustomCommandExecutor<? extends org.bukkit.command.CommandSender> getExecutor()
      Returns the executors that this command has
      Returns:
      the executors that this command has
    • setExecutor

      public void setExecutor(CustomCommandExecutor<? extends org.bukkit.command.CommandSender> executor)
      Sets the executors for this command
      Parameters:
      executor - the executors for this command
    • clearExecutors

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