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 Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource>
    The underlying command dispatcher
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dispatch(String command)
    Dispatches a command using the default client command source
    This is the most common way to execute commands
    void
    dispatch(String command, net.minecraft.command.CommandSource source)
    Dispatches a command with a specific command source
    This allows for custom command execution contexts
    Gets all registered commands
    This can be used to get information about available commands
    com.mojang.brigadier.CommandDispatcher<net.minecraft.command.CommandSource>
    Gets the underlying command dispatcher
    This can be used for advanced command handling
    void
    Registers a single command
    The command will be added to the list of commands and registered with the dispatcher
    void
    Registers multiple commands at once
    Each command will be added to the list of commands and registered with the dispatcher

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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