diff --git a/src/main/java/Sdf1_login/CustomScreenManager.java b/src/main/java/Sdf1_login/CustomScreenManager.java index 1c55a7f..80ab019 100644 --- a/src/main/java/Sdf1_login/CustomScreenManager.java +++ b/src/main/java/Sdf1_login/CustomScreenManager.java @@ -278,7 +278,7 @@ public class CustomScreenManager implements Listener { * 死循环弹窗:关闭即重弹,必须表态(签收或拒签)。 */ private void showBedrockSign(Player p, String pendingFile, String ackFileName, String content, ActionConfig actions) { - PendingSign ps = new PendingSign(pendingFile, ackFileName, content, actions); + PendingSign ps = new PendingSign(pendingFile, ackFileName, content, actions, pendingFile.contains(NOTIFICATION_DIR)); pendingSigs.put(p.getUniqueId(), ps); // ══ 125 续15 修复 Bug1(基岩版按钮无效):标题用纯 ASCII "AGREEMENT_SIGN" ══ @@ -502,7 +502,7 @@ public class CustomScreenManager implements Listener { * 死循环:未表态前每次上线都重新弹。 */ private void showCustomScreen(Player p, String pendingFile, String ackFileName, String content, ActionConfig actions) { - PendingSign ps = new PendingSign(pendingFile, ackFileName, content, actions); + PendingSign ps = new PendingSign(pendingFile, ackFileName, content, actions, pendingFile.contains(NOTIFICATION_DIR)); pendingSigs.put(p.getUniqueId(), ps); try { @@ -582,7 +582,7 @@ public class CustomScreenManager implements Listener { // 把用户协议专属处置套到 JSON 块场景(用户铁证:JSON 块配置 deny:kick,但被按用户协议规则处置)。 // 现改:提示乱写 + 立即执行当前 JSON 块 denyAction(kick/del/ban),两种处置彻底解耦。 player.sendMessage(Component.text("§c签名「" + sigTrim + "」与您的游戏ID(" + player.getName() + ")不匹配,闲杂人员过不了门禁,将执行拒签动作。")); - executeDenyAction(player, cur.actions); + executeDenyAction(player, cur.actions, cur.isJsonBlock); cleanupUI(player); pendingSigs.remove(player.getUniqueId()); draftSignatures.remove(player.getUniqueId()); @@ -694,7 +694,7 @@ public class CustomScreenManager implements Listener { // ★ 125 续15f 解耦:乱写签名=闲杂人员,走拒签路径(executeDenyAction)而非"用户协议送客"路径。 // 提示乱写 + 立即执行当前 JSON 块 denyAction(kick/del/ban),两种处置彻底解耦。 player.sendMessage(Component.text("§c签名「" + sigTrim + "」与您的游戏ID(" + player.getName() + ")不匹配,闲杂人员过不了门禁,将执行拒签动作。")); - executeDenyAction(player, cur.actions); + executeDenyAction(player, cur.actions, cur.isJsonBlock); cleanupUI(player); pendingSigs.remove(player.getUniqueId()); draftSignatures.remove(player.getUniqueId()); @@ -937,7 +937,7 @@ public class CustomScreenManager implements Listener { return; } // 执行拒签动作 - executeDenyAction(player, ps.actions); + executeDenyAction(player, ps.actions, ps.isJsonBlock); cleanupUI(player); pendingSigs.remove(player.getUniqueId()); draftSignatures.remove(player.getUniqueId()); @@ -990,31 +990,38 @@ public class CustomScreenManager implements Listener { } } - private void executeDenyAction(Player p, ActionConfig actions) { + private void executeDenyAction(Player p, ActionConfig actions, boolean jsonBlockSource) { // ★ 125 续11:入口重新读 action.json(用当前时刻值覆盖弹窗时刻的旧值) // 根因:弹窗时刻 parseActionConfig 读 action.json 失败走默认 kick → PendingSign.actions.denyAction=kick; // 拒签执行时重新读 action.json 成功(del),但旧代码仍用旧对象的 kick 值("动作挂错了")。 // 修复:executeDenyAction 入口先重新读 action.json,若读到合法 deny 值则覆盖 actions.denyAction。 + // ★ 125 续15h 解耦:JSON 块场景(jsonBlockSource=true)跳过重读 action.json—— + // JSON 块的 deny 来自 markdown 内嵌 json 块(已在 parseActionConfig 阶段正确读入 actions.denyAction), + // 不应被 用户协议/action.json 的 deny 值覆盖(15f 漏改根因:JSON 块 deny:kick 被 action.json del 覆盖 → 按用户协议处置)。 String oldDeny = actions.denyAction; - try { - File diagJson = new File(plugin.getDataFolder(), AGREEMENT_DIR + "/action.json"); - if (diagJson.exists()) { - String raw = new String(Files.readAllBytes(diagJson.toPath())); - plugin.getLogger().warning("[自定义屏幕][诊断] action.json 原文(路径: " + diagJson.getAbsolutePath() + "):\n" + raw); - // 解析重新读到的 deny 值(覆盖旧值) - ActionConfig fresh = new ActionConfig(); - parseJsonConfig(raw, fresh); - if (fresh.denyAction != null && !fresh.denyAction.isEmpty() - && !fresh.denyAction.equalsIgnoreCase(oldDeny)) { - plugin.getLogger().warning("[自定义屏幕][诊断] 重新读取 action.json 的 deny 值: " + fresh.denyAction - + "(弹窗时刻旧值: " + oldDeny + "),已覆盖"); - actions.denyAction = fresh.denyAction; + if (!jsonBlockSource) { + try { + File diagJson = new File(plugin.getDataFolder(), AGREEMENT_DIR + "/action.json"); + if (diagJson.exists()) { + String raw = new String(Files.readAllBytes(diagJson.toPath())); + plugin.getLogger().warning("[自定义屏幕][诊断] action.json 原文(路径: " + diagJson.getAbsolutePath() + "):\n" + raw); + // 解析重新读到的 deny 值(覆盖旧值) + ActionConfig fresh = new ActionConfig(); + parseJsonConfig(raw, fresh); + if (fresh.denyAction != null && !fresh.denyAction.isEmpty() + && !fresh.denyAction.equalsIgnoreCase(oldDeny)) { + plugin.getLogger().warning("[自定义屏幕][诊断] 重新读取 action.json 的 deny 值: " + fresh.denyAction + + "(弹窗时刻旧值: " + oldDeny + "),已覆盖"); + actions.denyAction = fresh.denyAction; + } + } else { + plugin.getLogger().warning("[自定义屏幕][诊断] action.json 不存在(路径: " + diagJson.getAbsolutePath() + "),沿用弹窗时刻值 " + oldDeny); } - } else { - plugin.getLogger().warning("[自定义屏幕][诊断] action.json 不存在(路径: " + diagJson.getAbsolutePath() + "),沿用弹窗时刻值 " + oldDeny); + } catch (Exception ex) { + plugin.getLogger().warning("[自定义屏幕][诊断] 读取 action.json 失败: " + ex.getMessage() + ",沿用弹窗时刻值 " + oldDeny); } - } catch (Exception ex) { - plugin.getLogger().warning("[自定义屏幕][诊断] 读取 action.json 失败: " + ex.getMessage() + ",沿用弹窗时刻值 " + oldDeny); + } else { + plugin.getLogger().info("[自定义屏幕][诊断] JSON 块场景,沿用 markdown 内嵌 json 块的 deny 值: " + oldDeny + "(不重读 action.json)"); } String action = normalizeAction(actions.denyAction); plugin.getLogger().info("[自定义屏幕] 玩家 " + p.getName() + " 拒签,执行动作: " + action @@ -1038,14 +1045,21 @@ public class CustomScreenManager implements Listener { // 阻断 5 分钟快速重连窗口内检查点1/2 的"自动登录"(f030帧铁证"您已自动登录!")。 // 重进时 autoLogin 漏斗命中 isDeletedByDeny → 强制 /reg 重新注册 + /login。 main.markDeletedByDeny(p.getName()); - p.kick(Component.text("您已拒签用户协议,账号已被删除并被踢出服务器,需重新注册后方可再次进入。如有疑问请联系管理员。")); + // ★ 125 续15h 解耦文案:用户协议 vs JSON 块公告 两种场景文案分开 + p.kick(Component.text(jsonBlockSource + ? "您已拒签该通知,账号已被删除并被踢出服务器,需重新注册后方可再次进入。如有疑问请联系管理员。" + : "您已拒签用户协议,账号已被删除并被踢出服务器,需重新注册后方可再次进入。如有疑问请联系管理员。")); break; case "kick": - p.kick(Component.text("您已拒签用户协议,已被踢出服务器。如有疑问请联系管理员。")); + p.kick(Component.text(jsonBlockSource + ? "您已拒签该通知,已被踢出服务器。如有疑问请联系管理员。" + : "您已拒签用户协议,已被踢出服务器。如有疑问请联系管理员。")); plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 已踢出(kick)"); break; case "ban": - p.ban("您已拒签用户协议,已被封禁 1 年。如有疑问请联系管理员。", + p.ban(jsonBlockSource + ? "您已拒签该通知,已被封禁 1 年。如有疑问请联系管理员。" + : "您已拒签用户协议,已被封禁 1 年。如有疑问请联系管理员。", java.time.Duration.ofDays(365), "Sdf1_login", false); plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 已封禁 1 年(ban)"); break; @@ -1067,7 +1081,9 @@ public class CustomScreenManager implements Listener { // ★ 125 续7:未知动作不再静默跳过(旧行为是"跳过执行",玩家看起来像"只关屏幕没后果"), // 保底执行 kick(最小副作用),同时大声 warning 提示管理员检查 action.json 配置。 plugin.getLogger().warning("[自定义屏幕] 未知拒签动作「" + action + "」(原始值「" + actions.denyAction + "」),已保底执行 kick。合法值:del/rm/delete/删号、kick/踢出、ban、banip"); - p.kick(Component.text("您已拒签用户协议,已被踢出服务器(拒签动作未识别,已执行保底踢出)。如有疑问请联系管理员。")); + p.kick(Component.text(jsonBlockSource + ? "您已拒签该通知,已被踢出服务器(拒签动作未识别,已执行保底踢出)。如有疑问请联系管理员。" + : "您已拒签用户协议,已被踢出服务器(拒签动作未识别,已执行保底踢出)。如有疑问请联系管理员。")); break; } } @@ -1203,7 +1219,7 @@ public class CustomScreenManager implements Listener { if (!draft.equalsIgnoreCase(p.getName())) { // ★ 125 续15f 解耦:聊天里乱写签名=闲杂人员,走拒签路径(executeDenyAction)而非"用户协议送客"路径。 p.sendMessage(Component.text("§c签名「" + draft + "」与您的游戏ID(" + p.getName() + ")不匹配,闲杂人员过不了门禁,将执行拒签动作。")); - executeDenyAction(p, ps.actions); + executeDenyAction(p, ps.actions, ps.isJsonBlock); cleanupUI(p); pendingSigs.remove(p.getUniqueId()); draftSignatures.remove(p.getUniqueId()); @@ -1263,7 +1279,7 @@ public class CustomScreenManager implements Listener { } else { // ★ 125 续15f 解耦:乱写签名=闲杂人员,走拒签路径(executeDenyAction)而非"用户协议送客"路径。 p.sendMessage(Component.text("§c签名「" + signature + "」与您的游戏ID(" + p.getName() + ")不匹配,闲杂人员过不了门禁,将执行拒签动作。")); - executeDenyAction(p, ps.actions); + executeDenyAction(p, ps.actions, ps.isJsonBlock); cleanupUI(p); pendingSigs.remove(p.getUniqueId()); draftSignatures.remove(p.getUniqueId()); @@ -1347,11 +1363,16 @@ public class CustomScreenManager implements Listener { final String ackFileName; // 回执文件名(全局协议=玩家名.md,玩家通知=原文件名) final String content; final ActionConfig actions; - PendingSign(String pendingFile, String ackFileName, String content, ActionConfig actions) { + // ★ 125 续15h:标记来源(用户协议 / JSON 块公告)。 + // JSON 块场景(pendingFile 含「公告/自定义屏幕」)的 actions.denyAction 来自 markdown 内嵌 json 块, + // executeDenyAction 不应再重新读 用户协议/action.json 覆盖(15f 漏改的根因:JSON 块 deny:kick 被用户协议 action.json 的 del 覆盖)。 + final boolean isJsonBlock; + PendingSign(String pendingFile, String ackFileName, String content, ActionConfig actions, boolean isJsonBlock) { this.pendingFile = pendingFile; this.ackFileName = ackFileName; this.content = content; this.actions = actions; + this.isJsonBlock = isJsonBlock; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 016a5bc..dec8bc6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -214,3 +214,6 @@ commands: credits: description: 信誉积分管理(上报/审批/记录/规则) usage: /credits [上报|审批|记录|规则] [参数] + rules: + description: 查看已签协议原文(CLI 分页 / GUI 书与笔) + usage: /rules [协议名|gui|prev|next|back|quit]