Class CommandBus

java.lang.Object
com.github.darksoulq.abyssallib.server.command.CommandBus

public class CommandBus extends Object
Manages registration and lifecycle of custom commands using the Brigadier command system. This class is intended to be initialized once via init(CommandDispatcher)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.mojang.brigadier.CommandDispatcher<io.papermc.paper.command.brigadier.CommandSourceStack>
    Retrieves the command dispatcher used for registering commands.
    static void
    init(com.mojang.brigadier.CommandDispatcher<io.papermc.paper.command.brigadier.CommandSourceStack> dispatcher)
    Initializes the CommandBus with the given Brigadier CommandDispatcher.
    static void
    register(String pluginId, Object handler)
    Registers all methods in the given handler class that are annotated with Command.
    static void
    Reloads all previously registered commands by unregistering and re-registering them.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CommandBus

      public CommandBus()
  • Method Details

    • init

      public static void init(com.mojang.brigadier.CommandDispatcher<io.papermc.paper.command.brigadier.CommandSourceStack> dispatcher)
      Initializes the CommandBus with the given Brigadier CommandDispatcher.
      Parameters:
      dispatcher - The command dispatcher used to register commands.
    • register

      public static void register(String pluginId, Object handler)
      Registers all methods in the given handler class that are annotated with Command. Each method must accept a single parameter of type LiteralArgumentBuilder.
      Parameters:
      pluginId - The mod ID this command belongs to.
      handler - The object containing command methods.
    • reloadAll

      public static void reloadAll()
      Reloads all previously registered commands by unregistering and re-registering them. (handled in /abyssallib reload)
    • getDispatcher

      public static com.mojang.brigadier.CommandDispatcher<io.papermc.paper.command.brigadier.CommandSourceStack> getDispatcher()
      Retrieves the command dispatcher used for registering commands.
      Returns:
      The command dispatcher.