Class SubCommand


  • public abstract class SubCommand
    extends Object
    Represents a subcommand that can be executed within a BaseCommand.

    This class defines the structure, metadata and optional behavior of a subcommand, while execution flow, logging and error handling are managed by BaseCommand.

    Version:
    0.0.8-alpha
    Author:
    jonagamerpro1234
    • Constructor Detail

      • SubCommand

        public SubCommand()
    • Method Detail

      • name

        public abstract String name()
        Gets the primary name of the subcommand.
        Returns:
        the name of the subcommand
        Since:
        0.0.1-alpha
      • permission

        public String permission()
        Gets the permission required to execute the subcommand.
        Returns:
        the permission string, or empty if none is required
        Since:
        0.0.1-alpha
      • requiresPermission

        public boolean requiresPermission()
        Checks whether this subcommand requires a permission to be executed.
        Returns:
        true if permission is required, false otherwise
        Since:
        0.0.1-alpha
      • onCommand

        public abstract boolean onCommand​(org.bukkit.command.CommandSender sender,
                                          String[] args)
        Executes the subcommand logic.

        Any exception thrown here will be handled by BaseCommand.

        Parameters:
        sender - the CommandSender executing the subcommand
        args - the full command arguments
        Returns:
        true if execution was successful
        Since:
        0.0.1-alpha
      • onTabList

        public List<String> onTabList​(org.bukkit.command.CommandSender sender,
                                      String[] args)
        Provides tab completion suggestions for this subcommand.
        Parameters:
        sender - the CommandSender requesting tab completion
        args - the command arguments
        Returns:
        a list of tab completion suggestions
        Since:
        0.0.7-alpha
      • allowConsole

        public boolean allowConsole()
        Determines whether this subcommand can be executed from the console.
        Returns:
        true if console execution is allowed
        Since:
        0.0.1-alpha
      • isEnabled

        public boolean isEnabled()
        Determines whether this subcommand is currently enabled.
        Returns:
        true if enabled
        Since:
        0.0.1-alpha
      • disabledMessage

        public String disabledMessage()
        Message displayed when the subcommand is disabled.
        Returns:
        the disabled message
        Since:
        0.0.1-alpha
      • isPlayerOnly

        public boolean isPlayerOnly()
        Indicates whether this subcommand can only be executed by players.
        Returns:
        true if player-only
        Since:
        0.0.7-alpha
      • aliases

        public List<String> aliases()
        Returns alternative names for this subcommand.
        Returns:
        a list of aliases
        Since:
        0.0.7-alpha
      • usage

        public String usage()
        Returns the usage information for this subcommand.
        Returns:
        the usage string
        Since:
        0.0.7-alpha
      • description

        public String description()
        Returns a short description of this subcommand.
        Returns:
        the description
        Since:
        0.0.7-alpha
      • debug

        protected void debug​(String message)
        Utility method for debug logging related to this subcommand.

        Messages will only be logged if CommandAPI debug mode is enabled.

        Parameters:
        message - the debug message
        Since:
        0.0.8-alpha