Skip to content

The CommandAPI should use MinecraftServer#getCommands instead of MinecraftServer.vanillaCommandDispatcher #406

@JorelAli

Description

@JorelAli

Description

As per this comment:

People using nms

Please move away from MinecraftServer.vanillaCommandDispatcher, instead, use MinecraftServer#getCommands().

This change supports the internal dispatcher being reloaded. We will need to figure out some api in order to properly support re-registering commands under some kind of lifecycle api.

Expected code

Replace the use of MINECRAFT_SERVER.vanillaCommandDispatcher in NMS implementations of NMS#getBrigadierDispatcher
https://github.com/JorelAli/CommandAPI/blob/2efd3a3ffdee797ab8b2a4b12784c9e5741d197a/commandapi-nms/commandapi-1.19.3/src/main/java/dev/jorel/commandapi/nms/NMS_1_19_3_R2.java#L395-L398

with MINECRAFT_SERVER.getCommands():

@Override
public final com.mojang.brigadier.CommandDispatcher<CommandSourceStack> getBrigadierDispatcher() {
    return MINECRAFT_SERVER.getCommands().getDispatcher();
}

Extra details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions