Class BrigadierCommandRegistry<S>
java.lang.Object
dev.ua.theroer.magicutils.commands.brigadier.BrigadierCommandRegistry<S>
- Type Parameters:
S- command source type
Shared Brigadier-backed command registry logic.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFactory for wrapping a command source into an audience.static final classRegistry for Brigadier argument resolvers.static interfaceResolves Brigadier argument shape for a command argument.static final classBrigadier-side shape for a single command argument. -
Constructor Summary
ConstructorsConstructorDescriptionBrigadierCommandRegistry(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.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. -
Method Summary
Modifier and TypeMethodDescriptionReturns the command manager.booleanReturns whether the registry has been initialized.voidregisterAllCommands(com.mojang.brigadier.CommandDispatcher<S> dispatcher, MagicCommand... commands) Registers all provided commands.voidregisterAllSpecs(com.mojang.brigadier.CommandDispatcher<S> dispatcher, CommandSpec<?>... specs) Registers all provided command specs.voidregisterCommand(com.mojang.brigadier.CommandDispatcher<S> dispatcher, MagicCommand command) Registers a single MagicUtils command.voidregisterSpec(com.mojang.brigadier.CommandDispatcher<S> dispatcher, CommandSpec<?> spec) Registers a compatibility command spec by converting it to aMagicCommand.protected voidRuns a task on the main thread when an executor is provided.
-
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 instanceplatform- command platform hooksparserRegistrar- 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 instanceplatform- command platform hooksparserRegistrar- 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
-
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 dispatchercommands- commands to register
-
registerAllSpecs
public void registerAllSpecs(com.mojang.brigadier.CommandDispatcher<S> dispatcher, CommandSpec<?>... specs) Registers all provided command specs.- Parameters:
dispatcher- Brigadier dispatcherspecs- command specs to register
-
registerCommand
public void registerCommand(com.mojang.brigadier.CommandDispatcher<S> dispatcher, MagicCommand command) Registers a single MagicUtils command.- Parameters:
dispatcher- Brigadier dispatchercommand- command instance
-
registerSpec
Registers a compatibility command spec by converting it to aMagicCommand.- Parameters:
dispatcher- Brigadier dispatcherspec- command spec
-
runOnMain
-