Package dev.cwhead.GravesX.module
Class ModuleCommandRegistrar
java.lang.Object
dev.cwhead.GravesX.module.ModuleCommandRegistrar
Registers and unregisters module-defined permissions and commands from
module.yml.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.bukkit.command.SimpleCommandMapReflectively obtains the server command map.private org.bukkit.command.CommandExecutorexecInstance(String fqcn, ModuleManager.LoadedModule lm, org.bukkit.command.Command cmd) Instantiates a command executor using the module class loader.private <T> Tinstantiate(Class<?> c, ModuleContext ctx, Class<T> type) private org.bukkit.configuration.file.YamlConfigurationLoads the module'smodule.ymlusing the module class loader.private org.bukkit.command.PluginCommandnewPluginCommand(String name, Graves owner) Creates aPluginCommandbound to the owner plugin.readAliases(Object val) Normalizes aliases from list, comma-separated string, or single value.private voidregisterCommands(ModuleManager.LoadedModule lm, org.bukkit.configuration.ConfigurationSection sec) Registers commands from thecommandssection and wires executors/tab-completers.(package private) voidprivate voidregisterPermissions(ModuleManager.LoadedModule lm, org.bukkit.configuration.ConfigurationSection sec) Registers permissions from thepermissionssection.private GravesXModuleTabCompletertabInstance(String fqcn, ModuleManager.LoadedModule lm, org.bukkit.command.Command cmd) Instantiates a tab completer using the module class loader.private voidunregister(org.bukkit.command.PluginCommand pc) Unregisters a command from the command map and removes it from known commands.(package private) voidUnregisters all permissions and commands previously registered for a module.
-
Field Details
-
plugin
-
cmds
-
perms
-
-
Constructor Details
-
ModuleCommandRegistrar
ModuleCommandRegistrar(Graves plugin)
-
-
Method Details
-
registerFor
-
unregisterFor
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'smodule.ymlusing the module class loader.- Parameters:
lm- Loaded module container.- Returns:
- Parsed YAML or
nullif not found or failed.
-
registerPermissions
private void registerPermissions(ModuleManager.LoadedModule lm, org.bukkit.configuration.ConfigurationSection sec) Registers permissions from thepermissionssection.- 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 thecommandssection and wires executors/tab-completers.- Parameters:
lm- Loaded module container.sec- Configuration section containing commands.
-
readAliases
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
nullif 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
nullif incompatible or failed.
-
instantiate
- Throws:
Exception
-
commandMap
private org.bukkit.command.SimpleCommandMap commandMap()Reflectively obtains the server command map.- Returns:
- Command map or
nullif unavailable.
-
newPluginCommand
Creates aPluginCommandbound to the owner plugin.- Parameters:
name- Command name.owner- Owner plugin.- Returns:
- New command or
nullon 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.
-