Package me.despical.commandframework
Class CommandRegistry
java.lang.Object
me.despical.commandframework.CommandRegistry
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final classA helper class that contains methods for matching commands and their corresponding tab completers. -
Method Summary
Modifier and TypeMethodDescriptionprotected @NotNull CommandRegistry.CommandMatcherprotected voidregisterCommand(Command command, Method method, Object instance) This method registers a command along with its associated method and instance.protected voidregisterCommands(@NotNull Object instance) Registers commands from the specified instance's class.voidsetCommandMap(@NotNull org.bukkit.command.CommandMap commandMap) Sets theCommandMapfor this instance.protected voidunregisterCommand(@NotNull String commandName) Unregisters a command and its associated tab completer if they are registered with the specified name.protected voidUnregisters all commands and tab completers that were registered using the instance of this object.
-
Method Details
-
setCommandMap
public void setCommandMap(@NotNull @NotNull org.bukkit.command.CommandMap commandMap) Sets theCommandMapfor this instance.- Parameters:
commandMap- theCommandMapto be set. Must be non-null.
-
registerCommands
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 benull.
-
registerCommand
This method registers a command along with its associated method and instance. When the command is executed, the specified method will be invoked. -
unregisterCommand
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 benullor empty.- Throws:
IllegalArgumentException- ifcommandNameisnullor an empty string.
-
unregisterCommands
protected void unregisterCommands()Unregisters all commands and tab completers that were registered using the instance of this object. -
getCommands
-
getSubCommands
-
getCommandMatcher
-