PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies

Home Page:https://papermc.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`send-namespaced: false` is returning Brigadier commands to `Player` although `.requires()` is not satisfied

riazufila opened this issue · comments

Expected behavior

When setting send-namespaced: true, Brigadier commands that have its .requires() return false won't appear for auto-completion (which i think is logical and expected).

Same thing should be expected when setting send-namespaced: false, Brigadier commands that have its .requires() return false will still not appear to Player, right? However, this is not the case, setting send-namespaced: false will result in Brigadier command that isn't satisfied by its .requires() to be shown and be available for autocomplete.

Observed/Actual behavior

Setting send-namespaced: false results in Brigadier commands that have its .requires() return false to be shown and be available for autocomplete.

Steps/models to reproduce

Don't forget to set send-namespaced: false. You should still be able to auto complete /sample a and /sample b i. Whereas, if you set send-namespaced: true, you can only autocomplete sample but cannot auto complete sample a and sample b i.

public class SamplePlugin extends JavaPlugin {
  @Override
  public void onEnable() {
    final LifecycleEventManager<Plugin> manager = this.getLifecycleManager();

    manager.registerEventHandler(
        LifecycleEvents.COMMANDS,
        event -> {
          final Commands commands = event.registrar();

          commands.register(
              Commands.literal("sample")
                  .then(
                      Commands.literal("a")
                          .requires(source -> false)
                          .executes(
                              context -> {
                                context.getSource().getSender().sendPlainMessage("sample A");
                                return Command.SINGLE_SUCCESS;
                              }))
                  .then(
                      Commands.literal("b")
                          .then(
                              Commands.argument("i", StringArgumentType.greedyString())
                                  .executes(
                                      context -> {
                                        context
                                            .getSource()
                                            .getSender()
                                            .sendPlainMessage("sample b i");
                                        return Command.SINGLE_SUCCESS;
                                      }))
                          .requires(source -> false))
                  .build());
        });
  }
}

Plugin and Datapack List

None.

Paper version

[13:41:08 INFO]: Checking version, please wait...
[13:41:09 INFO]: This server is running Paper version 1.21.1-57-master@b483da4 (2024-09-01T18:09:05Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
You are running the latest version

Other

No response