Skip to content

Redirect with brigadier API does not work as expected #10827

@xaanndeer

Description

@xaanndeer

Expected behavior

When redirecting aliases to a command using LiteralArgumentBuilder.redirect(LiteralCommandNode) the alias should execute said command.

Observed/Actual behavior

Aliases get sent to the client, however upon executing (without namespace) an unknown or incomplete command exception gets thrown. When using an alias without a namespace arguments don't get recognized and are marked as incorrect as well.

Steps/models to reproduce

Create a command using the brigadier API and add an alias that redirects to this command.

        LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("teleport");
        builder.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("example.command.teleport"))
                .then(Commands.argument("target", ArgumentTypes.player())
                .executes(source -> {
                    Player player = source.getArgument("target", PlayerSelectorArgumentResolver.class).resolve(source.getSource()).getFirst();
                    source.getSource().getSender().sendMessage("Teleporting to %s".formatted(player.getName()));
                    return 1;
                }));
        LiteralCommandNode<CommandSourceStack> literalCommandNode = builder.build();
        commands.register(javaPlugin.getPluginMeta(), literalCommandNode, "Teleport command", Collections.emptySet());
        commands.register(javaPlugin.getPluginMeta(), Commands.literal("tp").redirect(literalCommandNode).build(), "Teleport command", Collections.emptySet());

Try to run this command by using the alias without namespace: Arguments are marked as incorrect and Unknown or incomplete command

Plugin and Datapack List

3ceeae3645d821a0d27cf3402021b675
datapack_list

Paper version

30.05 01:35:37 [Server] INFO This server is running Paper version 1.20.6-121-master@a31dc90 (2024-05-29T21:07:31Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)
30.05 01:35:37 [Server] INFO You are 3 version(s) behind
30.05 01:35:37 [Server] INFO Download the new version at: https://papermc.io/downloads/paper
30.05 01:35:37 [Server] INFO Previous version: 1.20.6-115-9d6f2cc (MC: 1.20.6)

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: lowThis issue only describes a minor inconvenience.status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.type: bugSomething doesn't work as it was intended to.version: 1.20.6Game version 1.20.6

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions