Package dev.boze.api.addon
Class AddonDispatcher
java.lang.Object
dev.boze.api.addon.AddonDispatcher
Container class for addon command dispatching
Each addon has its own dispatcher that manages its commands
The dispatcher handles command registration, execution, and provides access to all registered commands
All addons must use this to register and handle commands
Each addon has its own dispatcher that manages its commands
The dispatcher handles command registration, execution, and provides access to all registered commands
All addons must use this to register and handle commands
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource> The underlying command dispatcher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDispatches a command using the default client command source
This is the most common way to execute commandsvoidDispatches a command with a specific command source
This allows for custom command execution contextsGets all registered commands
This can be used to get information about available commandscom.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource> Gets the underlying command dispatcher
This can be used for advanced command handlingvoidregisterCommand(AddonCommand command) Registers a single command
The command will be added to the list of commands and registered with the dispatchervoidregisterCommands(AddonCommand... commands) Registers multiple commands at once
Each command will be added to the list of commands and registered with the dispatcher
-
Field Details
-
dispatcher
public static final com.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource> dispatcherThe underlying command dispatcher
-
-
Constructor Details
-
AddonDispatcher
public AddonDispatcher()
-
-
Method Details
-
getDispatcher
public com.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource> getDispatcher()Gets the underlying command dispatcher
This can be used for advanced command handling- Returns:
- The command dispatcher
-
dispatch
Dispatches a command using the default client command source
This is the most common way to execute commands- Parameters:
command- The command to dispatch- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException- If the command has a syntax error
-
dispatch
public void dispatch(String command, net.minecraft.command.CommandSource source) throws com.mojang.brigadier.exceptions.CommandSyntaxException Dispatches a command with a specific command source
This allows for custom command execution contexts- Parameters:
command- The command to dispatchsource- The command source to use- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException- If the command has a syntax error
-
registerCommand
Registers a single command
The command will be added to the list of commands and registered with the dispatcher- Parameters:
command- The command to register
-
registerCommands
Registers multiple commands at once
Each command will be added to the list of commands and registered with the dispatcher- Parameters:
commands- The commands to register
-
getCommands
Gets all registered commands
This can be used to get information about available commands- Returns:
- List of all registered commands
-