Package de.craftsblock.craftsnet.command
Class CommandRegistry
java.lang.Object
de.craftsblock.craftsnet.command.CommandRegistry
The
CommandRegistry class manages and provides access to registered commands.
It allows commands to be retrieved, checked for existence, and executed.- Since:
- 2.2.0-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCommandRegistry(CraftsNet craftsNet) Constructs a new instance of the command registry. -
Method Summary
Modifier and TypeMethodDescription@NotNull CommandgetCommand(String name) Retrieves a command by name.booleanhasCommand(String name) Checks if a command with the given name exists.voidPerforms the execution of a command with the provided name and arguments.
-
Constructor Details
-
CommandRegistry
Constructs a new instance of the command registry.- Parameters:
craftsNet- The CraftsNet instance which instantiates this command registry.
-
-
Method Details
-
getCommand
Retrieves a command by name. If the command doesn't exist, it is created.- Parameters:
name- The name of the command to retrieve.- Returns:
- The command with the specified name or a new command if it doesn't exist.
-
hasCommand
Checks if a command with the given name exists.- Parameters:
name- The name of the command to check for existence.- Returns:
trueif a command with the specified name exists, otherwisefalse.
-
perform
Performs the execution of a command with the provided name and arguments.- Parameters:
name- The name of the command to execute.args- The arguments to pass to the command executor.
-