NoPermissionException fires with wrong permissions

未关闭
#365 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
cli

调研方向

首先,使用两个分别需要 permission1 和 permission2 的命令复现所提供的 Java 插件示例,然后跟踪 NoPermissionException 如何构建其消息。当发送者缺少这两个权限时,command1 仅报告 permission1,command2 仅报告 permission2,即表示完成。

由索引模型根据 Issue 内容生成。

描述

enhancement

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
主要语言
Java
星标
546
派生
61
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Incendo/cloud 的其他 Issue

查看 Incendo/cloud 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。