Class BaseCommand

  • All Implemented Interfaces:
    org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor

    public abstract class BaseCommand
    extends Object
    implements org.bukkit.command.TabExecutor
    BaseCommand is a flexible constructor for Bukkit commands that allows: 1. Registering subcommands. 2. Executing the main command logic if no subcommand is provided. 3. Tab completion for both subcommands and the main command.
    Version:
    0.0.9-alpha
    Author:
    jonagamerpro1234
    • Constructor Detail

      • BaseCommand

        public BaseCommand()
    • Method Detail

      • register

        public void register​(@NotNull
                             @NotNull org.bukkit.plugin.java.JavaPlugin plugin)
        Registers this command automatically using the provided JavaPlugin.
        Parameters:
        plugin - the JavaPlugin instance used to register the command
        Throws:
        IllegalStateException - if the command name has not been set or is empty
        Since:
        0.0.8-alpha
      • name

        public BaseCommand name​(String name)
        Sets the main command name.
        Parameters:
        name - the name of the main command
        Returns:
        this BaseCommand instance for chaining
        Since:
        0.0.7-alpha
      • addSubCommand

        public BaseCommand addSubCommand​(SubCommand subCommand)
        Adds a subcommand to this command.
        Parameters:
        subCommand - the subcommand to add
        Returns:
        this BaseCommand instance for chaining
        Since:
        0.0.7-alpha
      • addSubCommand

        public BaseCommand addSubCommand​(SubCommand... subCommands)
        Adds multiple subcommands to this command at once.
        Parameters:
        subCommands - the subcommands to add
        Returns:
        this BaseCommand instance for chaining
        Since:
        0.0.7-alpha
      • onCommandMain

        public boolean onCommandMain​(@NotNull
                                     @NotNull org.bukkit.command.CommandSender sender,
                                     String[] args)
        Logic executed when no subcommand is provided.
        Parameters:
        sender - the CommandSender executing the command
        args - the command arguments
        Returns:
        true if execution was successful
        Since:
        0.0.7-alpha
      • onTabMain

        public List<String> onTabMain​(@NotNull
                                      @NotNull org.bukkit.command.CommandSender sender,
                                      String[] args)
        Tab completion suggestions for the main command.
        Parameters:
        sender - the CommandSender requesting tab completion
        args - the command arguments
        Returns:
        a list of suggestions
        Since:
        0.0.7-alpha
      • onCommand

        public boolean onCommand​(@NotNull
                                 @NotNull org.bukkit.command.CommandSender sender,
                                 @NotNull
                                 @NotNull org.bukkit.command.Command command,
                                 @NotNull
                                 @NotNull String label,
                                 String @NotNull [] args)
        Handles command execution with debug, logging, and performance tracking.
        Specified by:
        onCommand in interface org.bukkit.command.CommandExecutor
        Since:
        0.0.8-alpha
      • onTabComplete

        public List<String> onTabComplete​(@NotNull
                                          @NotNull org.bukkit.command.CommandSender sender,
                                          @NotNull
                                          @NotNull org.bukkit.command.Command command,
                                          @NotNull
                                          @NotNull String alias,
                                          String @NotNull [] args)
        Handles tab completion for the main command and its subcommands.
        Specified by:
        onTabComplete in interface org.bukkit.command.TabCompleter
        Since:
        0.0.7-alpha
      • getName

        public String getName()