Class CommandRegistry

java.lang.Object
me.despical.commandframework.CommandRegistry

@Internal public class CommandRegistry extends Object
This class manages the registry of commands, sub-commands and tab completers associated with those commands. It also provides helper methods for matching commands and their corresponding tab completers.

This is an internal class and should not be instantiated or extended by any subclasses.

Since:
1.4.8

Created on 18.07.2024

Author:
Despical
  • Method Details

    • setCommandMap

      public void setCommandMap(@NotNull @NotNull org.bukkit.command.CommandMap commandMap)
      Sets the CommandMap for this instance.
      Parameters:
      commandMap - the CommandMap to be set. Must be non-null.
    • registerCommands

      protected void registerCommands(@NotNull @NotNull Object instance)
      Registers commands from the specified instance's class.

      This method scans the class of the provided instance and registers all commands defined within that class. The class should contain methods annotated to be recognized as commands.

      Parameters:
      instance - the instance of the class from which commands will be registered. Must not be null.
    • registerCommand

      protected void registerCommand(Command command, Method method, Object instance)
      This method registers a command along with its associated method and instance. When the command is executed, the specified method will be invoked.
      Parameters:
      command - the Command object representing the command to be registered.
      method - the Method object representing the method to be invoked when the command is executed.
      instance - the instance of the class that contains the command method.
    • unregisterCommand

      protected void unregisterCommand(@NotNull @NotNull String commandName)
      Unregisters a command and its associated tab completer if they are registered with the specified name.
      Parameters:
      commandName - the name of the command to be unregistered. Must not be null or empty.
      Throws:
      IllegalArgumentException - if commandName is null or an empty string.
    • unregisterCommands

      protected void unregisterCommands()
      Unregisters all commands and tab completers that were registered using the instance of this object.
    • getCommands

      @NotNull protected @NotNull Set<Command> getCommands()
    • getSubCommands

      @NotNull protected @NotNull Set<Command> getSubCommands()
    • getCommandMatcher

      @NotNull protected @NotNull CommandRegistry.CommandMatcher getCommandMatcher()