Class ModuleCommandRegistrar

java.lang.Object
dev.cwhead.GravesX.module.ModuleCommandRegistrar

final class ModuleCommandRegistrar extends Object
Registers and unregisters module-defined permissions and commands from module.yml.
  • Field Details

    • plugin

      private final Graves plugin
    • cmds

      private final Map<String,List<org.bukkit.command.PluginCommand>> cmds
    • perms

      private final Map<String,List<org.bukkit.permissions.Permission>> perms
  • Constructor Details

    • ModuleCommandRegistrar

      ModuleCommandRegistrar(Graves plugin)
  • Method Details

    • registerFor

      void registerFor(ModuleManager.LoadedModule lm)
    • unregisterFor

      void unregisterFor(ModuleManager.LoadedModule lm)
      Unregisters all permissions and commands previously registered for a module.
      Parameters:
      lm - Loaded module container.
    • loadModuleYaml

      private org.bukkit.configuration.file.YamlConfiguration loadModuleYaml(ModuleManager.LoadedModule lm)
      Loads the module's module.yml using the module class loader.
      Parameters:
      lm - Loaded module container.
      Returns:
      Parsed YAML or null if not found or failed.
    • registerPermissions

      private void registerPermissions(ModuleManager.LoadedModule lm, org.bukkit.configuration.ConfigurationSection sec)
      Registers permissions from the permissions section.
      Parameters:
      lm - Loaded module container.
      sec - Configuration section containing permission nodes.
    • registerCommands

      private void registerCommands(ModuleManager.LoadedModule lm, org.bukkit.configuration.ConfigurationSection sec)
      Registers commands from the commands section and wires executors/tab-completers.
      Parameters:
      lm - Loaded module container.
      sec - Configuration section containing commands.
    • readAliases

      private List<String> readAliases(Object val)
      Normalizes aliases from list, comma-separated string, or single value.
      Parameters:
      val - Raw aliases value.
      Returns:
      List of aliases, possibly empty.
    • execInstance

      private org.bukkit.command.CommandExecutor execInstance(String fqcn, ModuleManager.LoadedModule lm, org.bukkit.command.Command cmd)
      Instantiates a command executor using the module class loader. Prefers a (ModuleContext) constructor, then no-arg.
      Parameters:
      fqcn - Fully qualified class name.
      lm - Loaded module container.
      cmd - Command being registered.
      Returns:
      Executor instance or null if incompatible or failed.
    • tabInstance

      private GravesXModuleTabCompleter tabInstance(String fqcn, ModuleManager.LoadedModule lm, org.bukkit.command.Command cmd)
      Instantiates a tab completer using the module class loader. Prefers a (ModuleContext) constructor, then no-arg.
      Parameters:
      fqcn - Fully qualified class name.
      lm - Loaded module container.
      cmd - Command being registered.
      Returns:
      Tab completer instance or null if incompatible or failed.
    • instantiate

      private <T> T instantiate(Class<?> c, ModuleContext ctx, Class<T> type) throws Exception
      Throws:
      Exception
    • commandMap

      private org.bukkit.command.SimpleCommandMap commandMap()
      Reflectively obtains the server command map.
      Returns:
      Command map or null if unavailable.
    • newPluginCommand

      private org.bukkit.command.PluginCommand newPluginCommand(String name, Graves owner)
      Creates a PluginCommand bound to the owner plugin.
      Parameters:
      name - Command name.
      owner - Owner plugin.
      Returns:
      New command or null on failure.
    • unregister

      private void unregister(org.bukkit.command.PluginCommand pc)
      Unregisters a command from the command map and removes it from known commands.
      Parameters:
      pc - Plugin command to unregister.