NoPermissionException fires with wrong permissions
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Java
- Stars
- 548
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
When the command sender has no permissions relevant to the command manager, and attempts to use a command, NoPermissionException will have all permissions rather than the appropriate one.
Versions: cloud-paper 1.6.2 and 1.7.0-SNAPSHOT (bcc9d30)
Code:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
try {
var commandManager = PaperCommandManager.createNative(this, CommandExecutionCoordinator.simpleCoordinator());
commandManager.registerExceptionHandler(NoPermissionException.class, (ignored, exception) ->
getLogger().info(exception::getMessage)
);
commandManager.command(commandManager.commandBuilder("command1")
.permission("permission1")
.handler(context -> context.getSender().sendMessage("Handling command1"))
);
commandManager.command(commandManager.commandBuilder("command2")
.permission("permission2")
.handler(context -> context.getSender().sendMessage("Handling command2"))
);
} catch (Exception ignored) {}
}
}
Output:
[11:09:44 INFO]: SirSalad issued server command: /command1
[11:09:44 INFO]: [MyPlugin] Missing permission '(permission2)|(permission1)' <-- should only have permission1
[11:09:47 INFO]: SirSalad issued server command: /command2
[11:09:47 INFO]: [MyPlugin] Missing permission '(permission2)|(permission1)' <-- should only have permission2
[11:09:58 INFO]: SirSalad issued server command: /lp user SirSalad permission set permission1 true
[11:10:03 INFO]: SirSalad issued server command: /command1
[11:10:05 INFO]: SirSalad issued server command: /command2
[11:10:05 INFO]: [MyPlugin] Missing permission 'permission2' <-- this is correct
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied Java plugin example with two commands requiring permission1 and permission2, then trace how NoPermissionException builds its message. Done means command1 reports only permission1 and command2 reports only permission2 when the sender lacks both permissions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100