public interface CommandRegistrationCallback
To register some commands, you would register an event listener and implement the callback.
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
// For example, this command is only registered on an integrated server
if (!dedicated) dispatcher.register(CommandManager.literal("integrated_command").executes(context -> {...}));
})};
| Modifier and Type | Field and Description |
|---|---|
static Event<CommandRegistrationCallback> |
EVENT |
| Modifier and Type | Method and Description |
|---|---|
void |
register(com.mojang.brigadier.CommandDispatcher<net.minecraft.server.command.ServerCommandSource> dispatcher,
boolean dedicated)
Called when the server is registering commands.
|
static final Event<CommandRegistrationCallback> EVENT
void register(com.mojang.brigadier.CommandDispatcher<net.minecraft.server.command.ServerCommandSource> dispatcher,
boolean dedicated)
dispatcher - the command dispatcher to register commands to.dedicated - whether the server this command is being registered on is a dedicated server.