Class AutoCommandRegistrar

java.lang.Object
com.zetaplugins.zetacore.command.registration.AutoCommandRegistrar
All Implemented Interfaces:
CommandRegistrar

public class AutoCommandRegistrar extends Object implements CommandRegistrar
Manages the registration of commands and tab completers for a plugin. Use the Command annotation to mark command classes for automatic registration. Use the TabCompleterHandler annotation to mark tab completer classes for automatic registration.
  • Constructor Details

    • AutoCommandRegistrar

      public AutoCommandRegistrar(JavaPlugin plugin, String packagePrefix)
      Parameters:
      plugin - The JavaPlugin instance.
      packagePrefix - The package prefix to scan for annotated classes.
    • AutoCommandRegistrar

      public AutoCommandRegistrar(JavaPlugin plugin, String packagePrefix, String commandNamespace)
      Parameters:
      plugin - The JavaPlugin instance.
      packagePrefix - The package prefix to scan for annotated classes.
      commandNamespace - The namespace to use for the command. (e.g. "myplugin" for /myplugin:command)
    • AutoCommandRegistrar

      public AutoCommandRegistrar(JavaPlugin plugin, String packagePrefix, String commandNamespace, ServiceRegistry serviceRegistry)
  • Method Details

    • registerAllCommands

      public List<String> registerAllCommands()
      Registers all commands annotated with Command and tab completers annotated with TabCompleterHandler.
      Specified by:
      registerAllCommands in interface CommandRegistrar
      Returns:
      A list of names of the registered commands.
    • registerAllCommands

      public List<String> registerAllCommands(Predicate<String> commandNameFilter)
      Registers all commands annotated with Command and tab completers annotated with TabCompleterHandler.
      Parameters:
      commandNameFilter - A predicate to filter which command names to register.
      Returns:
      A list of names of the registered commands.
    • registerCommand

      public void registerCommand(String name, CommandExecutor executor, TabCompleter tabCompleter)
      Manually registers a command defined in the plugin.yml
      Specified by:
      registerCommand in interface CommandRegistrar
      Parameters:
      name - The name of the command
      executor - The executor of the command
      tabCompleter - The tab completer of the command