Class AddonDispatcher

java.lang.Object
dev.boze.api.addon.AddonDispatcher

public class AddonDispatcher extends Object
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
  • Field Details

    • dispatcher

      public static final com.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource> dispatcher
      The 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

      public void dispatch(String command) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      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 dispatch
      source - The command source to use
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException - If the command has a syntax error
    • registerCommand

      public void registerCommand(AddonCommand command)
      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

      public void registerCommands(AddonCommand... commands)
      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

      public List<AddonCommand> getCommands()
      Gets all registered commands

      This can be used to get information about available commands
      Returns:
      List of all registered commands