Permissions for optional player argument

So I have 1 command set up with 2 aliases, /fw and /firework. when used it shoots a random firework off with the sender as the target, I also want to be able to specify another player but cannot figure out how to do the perm. Im going the wrong way about it for sure. This is what I have. I had some of it commented out cause I realized you arent allowed 2 commands with the same alias but Im not sure how using child commands works because the argument for the command would be a players name so like /fw frostfled
Capture

look below at @dualspiral … Much better

The “fireworkOther” is in the right direction. Just check if they have the “other” permission in the actual executor if the player is present

You want GenericArguments.requiringPermission(CommandElement, string).

        CommandSpec.builder()
                .description(Text.of("your description"))
                .permission("fireworklauncher.self") // everyone will need this
                .arguments(
                        GenericArguments.requiringPermission(
                                GenericArguments.optional(
                                        GenericArguments.player(Text.of("PlayerName"))
                                ),
                                "fireworklauncher.others" // this is needed as well as your self permission
                        )
                )
                .executor(new FireworkCommand())
                .build();

Then check to see if the player is in the executor using CommandContext#getOne("PlayerName").isPresent(), defaulting to the source if not.

1 Like

thank you very much, so you can add a second permission within the arguments? I was trying to find a way but couldnt so I ended up creating two seperate commands as a fix for now. Ill go back and change it now. Much appreciated!