Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
riazufila opened this issue Sep 6, 2024 · 0 comments
Labels
status: needs triage type: bug Something doesn't work as it was intended to. version: 1.21.1

Comments

@riazufila
Copy link

riazufila commented Sep 6, 2024

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

@riazufila riazufila added status: needs triage type: bug Something doesn't work as it was intended to. labels Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: bug Something doesn't work as it was intended to. version: 1.21.1
Projects
Status: 🕑 Needs Triage
Development

No branches or pull requests

1 participant