Skip to content

Entity selectors do not work for players without permission on 1.21.1 #612

@willkroboth

Description

@willkroboth

CommandAPI version

9.6.0

Minecraft version

1.21.1

Are you shading the CommandAPI?

No

What I did

Registered a command that uses a entity selector:

new CommandAPICommand("test")
    .withArguments(new EntitySelectorArgument.ManyEntities("entities"))
    .executes(info -> {
        List<Entity> entities = info.args().getUnchecked("entities");

        assert entities != null;

        info.sender().sendMessage(entities.toString());
    })
    .register();

What actually happened

Trying to use the selector on 1.21.1/1.21.3 Paper or 1.21.3 Spigot gives the Selector not allowed message:

image

On 1.21.1 Spigot, executing the command does work. However, the suggestions say the selector is not allowed.

image

What should have happened

On Spigot and Paper 1.20.6, the entity selector works without an error:

image

Server logs and CommandAPI config

No response

Other

Originally reported by mikey in the CommandAPI Discord.

This behavioral difference is most likely due to Mojang changing how entity selectors are parsed in 1.21.1. As explored in https://haykam.com/blog/entity-selector-stack-overflow-crash, non-operator players with modded clients could crash a server with a stack overflow by executing a command containing an entity selector with a deeply nested nbt tag. Mojang "fixed" this exploit by refusing to parse entity selectors if the sender did not have vanilla permission level 2 or higher. The CommandAPI's documentation could add a note about this, recommending that developers require permission to access entity selectors in their commands.

Note that on Paper 1.21.1, giving the player the permission minecraft.command.selector allows them to execute the command with the selector as expected. Oddly, Paper doesn't seem to mention this in their documentation (https://docs.papermc.io/paper/reference/permissions), so this might just be a documentation issue on their part? The CommandAPI's documentation might also want to include a note about this given how it works differently on Spigot, where you can always use the selector. Although, on Spigot the suggestions don't work since the client always seems to think that they cannot use the selector. Probably too late though to get whatever fix Paper applied to the suggestions with the permission on Spigot.

The entity selector not working for 1.21.3 might just be a bump in the road as Spigot and Paper figure out their releases. Paper has an issue that might be related to this PaperMC/Paper#11562? I'm not sure if a similar issue exists on Spigot's tracker.

In general, I'm not entirely sure if the CommandAPI can do something about this. This might just be upstream problems with Spigot and Paper. But it's a little confusing with so many versions to look at doing slightly different things, so more investigation may be needed :P.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions