Class Command

java.lang.Object
redempt.redlib.commandmanager.Command
Direct Known Subclasses:
CommandCollection.MergedBaseCommand

public class Command extends Object
Represents a command which can be registered
  • Field Details

    • children

      protected List<Command> children
    • plugin

      protected org.bukkit.plugin.Plugin plugin
    • names

      protected String[] names
    • hook

      protected String hook
    • help

      protected String help
    • topLevel

      protected boolean topLevel
    • parent

      protected Command parent
  • Constructor Details

  • Method Details

    • showHelp

      public boolean showHelp(org.bukkit.command.CommandSender sender)
      Shows the help to a CommandSender
      Parameters:
      sender - The sender to show the help to
      Returns:
      True if the help was shown to the user, false if the usage was shown instead
    • getHelpRecursive

      protected String getHelpRecursive(org.bukkit.command.CommandSender sender, int level)
    • getFullName

      public String getFullName()
      Returns:
      The expanded name of the command, plus arguments
    • getArgsDisplay

      public String getArgsDisplay()
      Returns:
      The display of the arguments for this command
    • getExpandedName

      public String getExpandedName()
      Returns:
      The name of the command concatenated with its parents' names
    • register

      public void register(String prefix, Object... listeners)
      Registers this command and its children
      Parameters:
      prefix - The fallback prefix
      listeners - The listener objects containing method hooks
    • createHookMap

      protected Map<String,Command.MethodHook> createHookMap(Object... listeners)
    • registerHook

      protected void registerHook(Map<String,Command.MethodHook> hooks, org.bukkit.plugin.Plugin plugin)
    • tab

      protected List<String> tab(org.bukkit.command.CommandSender sender, String[] args)
    • execute

      protected Result<Boolean,String> execute(org.bukkit.command.CommandSender sender, String[] args, List<Object> prepend)
    • runHook

      protected Result<Boolean,String> runHook(org.bukkit.command.CommandSender sender, String[] args, List<Object> prepend, List<Result<Boolean,String>> results)
    • nameMatches

      public boolean nameMatches(String name)
      Check if a name matches any of this command's aliases
      Parameters:
      name - The name to check
      Returns:
      Whether the name matches any of this command's aliases
    • getDepth

      public int getDepth()
    • getType

      protected static ArgType<?> getType(String name, ArgType<?>[] types)
    • getName

      public String getName()
      Returns:
      The command's primary name/first alias
    • lastArgTakesAll

      public boolean lastArgTakesAll()
      Returns:
      Whether the last argument in this command is consuming or vararg
    • getAliases

      public String[] getAliases()
      Returns:
      All of the command's names/aliases
    • isPostArg

      public boolean isPostArg()
      Returns:
      Whether this subcommand comes after the arguments of its parent
    • getHelp

      public String getHelp()
      Returns:
      The command's help message
    • getPermission

      public String getPermission()
      Returns:
      Nullable. The permission required to run the command