Class AllianceCommandManager
This manager maintains a mapping between AlliancePlugin
instances and their associated AllianceCommandExecutors,
allowing isolation per extension and centralized command resolution.
-
Field Summary
FieldsModifier and TypeFieldDescriptionStores commands grouped by their owning plugin.Responsible for injecting commands into Bukkit's command map without requiring plugin.yml declarations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves all registered command names, including aliases, formatted with a leading '/'.getAllCommandNames(AlliancePlugin plugin) Retrieves all command names (including aliases) for a specific plugin.Retrieves an immutable list of all registered command executors.getCommand(String name) Retrieves a command by its primary name or any of its aliases.voidregisterCommand(AlliancePlugin plugin, AllianceCommandExecutor command) Registers a command under a specific plugin.voidunregisterCommands(AlliancePlugin extension) Unregisters all commands associated with a specific plugin.
-
Field Details
-
commands
Stores commands grouped by their owning plugin.Uses
ConcurrentHashMapto allow thread-safe access in environments where commands may be registered dynamically at runtime. -
fakeCommandRegister
Responsible for injecting commands into Bukkit's command map without requiring plugin.yml declarations.This enables dynamic command registration at runtime.
-
-
Constructor Details
-
AllianceCommandManager
public AllianceCommandManager()
-
-
Method Details
-
registerCommand
Registers a command under a specific plugin.The command is stored internally and also registered into Bukkit's command system via
FakeCommandRegister.- Parameters:
plugin- the owning plugincommand- the command executor instance
-
getCommand
Retrieves a command by its primary name or any of its aliases.The lookup is case-insensitive and searches across all registered plugins.
- Parameters:
name- the command name or alias- Returns:
- an
Optionalcontaining the command if found
-
getAllCommands
Retrieves an immutable list of all registered command executors.This method aggregates commands from all plugins into a single collection.
- Returns:
- unmodifiable list of all commands
-
getAllCommandNames
Retrieves all registered command names, including aliases, formatted with a leading '/'.Useful for command parsing or intercepting raw command input.
- Returns:
- list of all command names with prefix
-
getAllCommandNames
Retrieves all command names (including aliases) for a specific plugin.Unlike
getAllCommandNames(), this method does not include the '/' prefix.- Parameters:
plugin- the plugin whose commands should be retrieved- Returns:
- list of command names, or empty list if none are registered
-
unregisterCommands
Unregisters all commands associated with a specific plugin.This removes the commands from the internal registry, but does not explicitly remove them from Bukkit's command map unless handled separately by
FakeCommandRegister.- Parameters:
extension- the plugin whose commands should be removed
-