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, buildContext, selection) -> {
// For example, this command is only registered on an integrated server like the vanilla publish command
if (selection.includeIntegrated) dispatcher.register(Commands.literal("integrated_command").executes(context -> {...}));
});
}-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidregister(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher, net.minecraft.commands.CommandBuildContext buildContext, net.minecraft.commands.Commands.CommandSelection selection) Called when the server is registering commands.
-
Field Details
-
EVENT
-
-
Method Details
-
register
void register(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher, net.minecraft.commands.CommandBuildContext buildContext, net.minecraft.commands.Commands.CommandSelection selection) Called when the server is registering commands.- Parameters:
dispatcher- the command dispatcher to register commands tobuildContext- object exposing access to the game's holdersselection- environment selection the registrations should be done for, used for commands that are dedicated or integrated server only
-