Interface CommandRegistrationCallback


public interface CommandRegistrationCallback
Callback for when a server registers all commands.

To register some commands, you would register an event listener and implement the callback.


 CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
     // For example, this command is only registered on an integrated server like the vanilla publish command
     if (environment.integrated) dispatcher.register(CommandManager.literal("integrated_command").executes(context -> {...}));
 })};
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    register(com.mojang.brigadier.CommandDispatcher<net.minecraft.server.command.ServerCommandSource> dispatcher, net.minecraft.command.CommandRegistryAccess registryAccess, net.minecraft.server.command.CommandManager.RegistrationEnvironment environment)
    Called when the server is registering commands.
  • Field Details

  • Method Details

    • register

      void register(com.mojang.brigadier.CommandDispatcher<net.minecraft.server.command.ServerCommandSource> dispatcher, net.minecraft.command.CommandRegistryAccess registryAccess, net.minecraft.server.command.CommandManager.RegistrationEnvironment environment)
      Called when the server is registering commands.
      Parameters:
      dispatcher - the command dispatcher to register commands to
      registryAccess - object exposing access to the game's registries
      environment - environment the registrations should be done for, used for commands that are dedicated or integrated server only