diff --git a/_tmp.class b/_tmp.class new file mode 100644 index 0000000..d3f42ea Binary files /dev/null and b/_tmp.class differ diff --git a/src/main/java/Sdf1_login/CustomScreenManager.java b/src/main/java/Sdf1_login/CustomScreenManager.java index 44a276b..5d7856b 100644 --- a/src/main/java/Sdf1_login/CustomScreenManager.java +++ b/src/main/java/Sdf1_login/CustomScreenManager.java @@ -1,6 +1,7 @@ package Sdf1_login; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickCallback; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -467,22 +468,57 @@ public class CustomScreenManager implements Listener { .build(); // ConfirmationType:签收(yes)+ 拒签(no) - io.papermc.paper.registry.data.dialog.type.ConfirmationType type = - io.papermc.paper.registry.data.dialog.type.DialogType.confirmation( - io.papermc.paper.registry.data.dialog.ActionButton.create( - Component.text("§a§l✔ 签收"), - Component.text("确认签收用户协议"), - 200, - null - ), - io.papermc.paper.registry.data.dialog.ActionButton.create( - Component.text("§c§l✘ 拒签"), - Component.text("执行 " + ps.actions.denyAction + " 动作"), - 200, - null + // ★ 125 续8:两个按钮都挂 DialogAction.customClick 回调(旧代码第4参传 null → 按钮点击只关弹窗不执行任何 Java 代码, + // 这是「点拒签/签收都只是关屏幕、action 没执行」的根因)。回调里 audience=点按钮的玩家, + // 响应数据(DialogResponseView)含 DialogInput 的 key-value(signature 等),可判断 yes/no。 + io.papermc.paper.registry.data.dialog.ActionButton acceptBtn = + io.papermc.paper.registry.data.dialog.ActionButton.create( + Component.text("§a§l✔ 签收"), + Component.text("确认签收用户协议"), + 200, + io.papermc.paper.registry.data.dialog.action.DialogAction.customClick( + (response, audience) -> { + // audience = 点按钮的玩家(Audience 类型,实际是 Player) + if (!(audience instanceof Player player)) return; + PendingSign cur = pendingSigs.get(player.getUniqueId()); + if (cur == null) return; + // 签名从 DialogInput key="signature" 取 + String signature = response.getText("signature"); + if (signature == null || signature.isEmpty()) { + player.sendMessage(Component.text("§c请先填写签名(您的游戏ID)再点签收")); + return; + } + if (!signature.equalsIgnoreCase(player.getName())) { + player.sendMessage(Component.text("§c签名与您的游戏ID不匹配,请重新填写")); + return; + } + handleAccept(player, cur, signature.trim()); + }, + ClickCallback.Options.builder().build() ) ); + io.papermc.paper.registry.data.dialog.ActionButton denyBtn = + io.papermc.paper.registry.data.dialog.ActionButton.create( + Component.text("§c§l✘ 拒签"), + Component.text("执行 " + ps.actions.denyAction + " 动作"), + 200, + io.papermc.paper.registry.data.dialog.action.DialogAction.customClick( + (response, audience) -> { + if (!(audience instanceof Player player)) return; + PendingSign cur = pendingSigs.get(player.getUniqueId()); + if (cur == null) return; + String signature = response.getText("signature"); + confirmDeny(player, new File(cur.pendingFile).getName(), + signature != null ? signature.trim() : ""); + }, + ClickCallback.Options.builder().build() + ) + ); + + io.papermc.paper.registry.data.dialog.type.ConfirmationType type = + io.papermc.paper.registry.data.dialog.type.DialogType.confirmation(acceptBtn, denyBtn); + io.papermc.paper.dialog.Dialog dialog = io.papermc.paper.dialog.Dialog.create( builder -> builder.empty() .base(base) @@ -659,17 +695,46 @@ public class CustomScreenManager implements Listener { /** * 执行拒签动作。 */ + /** + * 拒签动作归一化:trim + 别名映射(支持中文别名与常见英文变体)。 + * del/rm/delete/remove/delaccount/删号/删号 → del + * kick/踢出/踢掉/踢 → kick + * ban/banip 保持原样(精确匹配) + * 未知值 → 原样返回(由 executeDenyAction 的 default 分支兜底为 kick) + */ + private static String normalizeAction(String raw) { + if (raw == null) return ""; + String a = raw.trim().toLowerCase(); + switch (a) { + case "rm": + case "delete": + case "remove": + case "delaccount": + case "删号": + case "删除": + return "del"; + case "踢出": + case "踢掉": + case "踢": + return "kick"; + default: + return a; // del/kick/ban/banip 及其它未知值原样 + } + } + private void executeDenyAction(Player p, ActionConfig actions) { - String action = actions.denyAction; + String action = normalizeAction(actions.denyAction); plugin.getLogger().info("[自定义屏幕] 玩家 " + p.getName() + " 拒签,执行动作: " + action); Main main = (Main) plugin; - switch (action.toLowerCase()) { - case "del", "rm": + switch (action) { + case "del": // 删号:先删 DB 记录再踢出 try { if (main.getDb() != null) { main.getDb().deleteUser(p.getName()); plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 账号已删除(del/rm)"); + } else { + plugin.getLogger().warning("[自定义屏幕] " + p.getName() + " 拒签 del 动作但 DB 未初始化,跳过删号仅踢出"); } } catch (Exception ex) { plugin.getLogger().warning("[自定义屏幕] 删号失败: " + ex.getMessage()); @@ -700,7 +765,10 @@ public class CustomScreenManager implements Listener { } break; default: - plugin.getLogger().warning("[自定义屏幕] 未知拒签动作: " + action + ",跳过执行"); + // ★ 125 续7:未知动作不再静默跳过(旧行为是"跳过执行",玩家看起来像"只关屏幕没后果"), + // 保底执行 kick(最小副作用),同时大声 warning 提示管理员检查 action.json 配置。 + plugin.getLogger().warning("[自定义屏幕] 未知拒签动作「" + action + "」(原始值「" + actions.denyAction + "」),已保底执行 kick。合法值:del/rm/delete/删号、kick/踢出、ban、banip"); + p.kick(Component.text("您已拒签用户协议,已被踢出服务器(拒签动作未识别,已执行保底踢出)。如有疑问请联系管理员。")); break; } } @@ -760,10 +828,11 @@ public class CustomScreenManager implements Listener { if (obj.has("deny")) { com.google.gson.JsonElement el = obj.get("deny"); if (el.isJsonPrimitive()) { - config.denyAction = el.getAsString(); + // ★ 125 续7:解析即归一化(trim+别名),保证 GUI 文案与 executeDenyAction 判定一致 + config.denyAction = normalizeAction(el.getAsString()); } else if (el.isJsonObject()) { com.google.gson.JsonObject dobj = el.getAsJsonObject(); - if (dobj.has("action")) config.denyAction = dobj.get("action").getAsString(); + if (dobj.has("action")) config.denyAction = normalizeAction(dobj.get("action").getAsString()); } } } catch (Exception ignored) {}