Class BrigadierCommandRegistry<S>

java.lang.Object
dev.ua.theroer.magicutils.commands.brigadier.BrigadierCommandRegistry<S>
Type Parameters:
S - command source type

public class BrigadierCommandRegistry<S> extends Object
Shared Brigadier-backed command registry logic.
  • Constructor Details

    • BrigadierCommandRegistry

      public BrigadierCommandRegistry(String modName, String permissionPrefix, LoggerCore loggerCore, CommandPlatform<S> platform, Consumer<TypeParserRegistry<S>> parserRegistrar, BrigadierCommandRegistry.AudienceFactory<S> audienceFactory, BiConsumer<S,Runnable> mainThreadExecutor, TaskScheduler scheduler)
      Creates a Brigadier-backed command registry.
      Parameters:
      modName - mod namespace (nullable)
      permissionPrefix - permission prefix (nullable)
      loggerCore - logger core instance
      platform - command platform hooks
      parserRegistrar - parser registrar callback (nullable)
      audienceFactory - audience factory (nullable)
      mainThreadExecutor - main thread executor (nullable)
      scheduler - task scheduler (nullable; shared by default)
    • BrigadierCommandRegistry

      public BrigadierCommandRegistry(String modName, String permissionPrefix, LoggerCore loggerCore, CommandPlatform<S> platform, Consumer<TypeParserRegistry<S>> parserRegistrar, BrigadierCommandRegistry.AudienceFactory<S> audienceFactory, BiConsumer<S,Runnable> mainThreadExecutor, TaskScheduler scheduler, Consumer<BrigadierCommandRegistry.BrigadierArgumentRegistry<S>> brigadierRegistrar)
      Creates a Brigadier-backed command registry with optional Brigadier argument resolvers.
      Parameters:
      modName - mod namespace (nullable)
      permissionPrefix - permission prefix (nullable)
      loggerCore - logger core instance
      platform - command platform hooks
      parserRegistrar - parser registrar callback (nullable)
      audienceFactory - audience factory (nullable)
      mainThreadExecutor - main thread executor (nullable)
      scheduler - task scheduler (nullable; shared by default)
      brigadierRegistrar - Brigadier argument registrar callback (nullable)
  • Method Details

    • commandManager

      public CommandManager<S> commandManager()
      Returns the command manager.
      Returns:
      command manager
    • initialized

      public boolean initialized()
      Returns whether the registry has been initialized.
      Returns:
      true when initialized
    • registerAllCommands

      public void registerAllCommands(com.mojang.brigadier.CommandDispatcher<S> dispatcher, MagicCommand... commands)
      Registers all provided commands.
      Parameters:
      dispatcher - Brigadier dispatcher
      commands - commands to register
    • registerAllSpecs

      public void registerAllSpecs(com.mojang.brigadier.CommandDispatcher<S> dispatcher, CommandSpec<?>... specs)
      Registers all provided command specs.
      Parameters:
      dispatcher - Brigadier dispatcher
      specs - command specs to register
    • registerCommand

      public void registerCommand(com.mojang.brigadier.CommandDispatcher<S> dispatcher, MagicCommand command)
      Registers a single MagicUtils command.
      Parameters:
      dispatcher - Brigadier dispatcher
      command - command instance
    • registerSpec

      public void registerSpec(com.mojang.brigadier.CommandDispatcher<S> dispatcher, CommandSpec<?> spec)
      Registers a compatibility command spec by converting it to a MagicCommand.
      Parameters:
      dispatcher - Brigadier dispatcher
      spec - command spec
    • runOnMain

      protected void runOnMain(S source, Runnable task)
      Runs a task on the main thread when an executor is provided.
      Parameters:
      source - command source
      task - task to run