PaperMC / PaperMC/Paper

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

Open
#11,361 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: needs triage type: bug version: 1.21.1
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Commands registration and player autocomplete paths for the send-namespaced setting, then compare how each path applies Brigadier .requires() predicates. Reproduce the sample with send-namespaced set to false and true; done means commands whose predicate returns false are absent from player autocomplete in both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.