diff --git a/src/main/java/Sdf1_login/CustomScreenManager.java b/src/main/java/Sdf1_login/CustomScreenManager.java index 5d7856b..31e8026 100644 --- a/src/main/java/Sdf1_login/CustomScreenManager.java +++ b/src/main/java/Sdf1_login/CustomScreenManager.java @@ -471,31 +471,37 @@ public class CustomScreenManager implements Listener { // ★ 125 续8:两个按钮都挂 DialogAction.customClick 回调(旧代码第4参传 null → 按钮点击只关弹窗不执行任何 Java 代码, // 这是「点拒签/签收都只是关屏幕、action 没执行」的根因)。回调里 audience=点按钮的玩家, // 响应数据(DialogResponseView)含 DialogInput 的 key-value(signature 等),可判断 yes/no。 + // ★ 125 续9:两个按钮共用一个 customClick 回调(避免 ConfirmationType 的 yes/no 按钮在 Paper 26.2 + // 客户端协议层 key 冲突导致点「同意」误触发拒签回调)。回调里通过「签名是否匹配玩家名」 + // 推断意图:签名非空且==玩家名 → 签收(handleAccept);签名空或!=玩家名 → 拒签(confirmDeny)。 + // 这样即使 Paper 把 yes 按钮点击路由到 reject 回调,签名匹配时仍自动转签收,杜绝「同意被踢出」。 + final io.papermc.paper.registry.data.dialog.action.DialogActionCallback sharedCallback = + (response, audience) -> { + if (!(audience instanceof Player player)) return; + PendingSign cur = pendingSigs.get(player.getUniqueId()); + if (cur == null) return; + String signature = response.getText("signature"); + String sigTrim = signature != null ? signature.trim() : ""; + // 推断意图:签名匹配玩家名 → 签收;否则 → 拒签 + boolean isAcceptIntent = !sigTrim.isEmpty() && sigTrim.equalsIgnoreCase(player.getName()); + if (isAcceptIntent) { + // 签收:落盘回执单 + handleAccept(player, cur, sigTrim); + } else { + // 拒签:执行 del/kick/ban 动作 + confirmDeny(player, new File(cur.pendingFile).getName(), sigTrim); + } + }; + final ClickCallback.Options sharedOptions = ClickCallback.Options.builder() + .uses(ClickCallback.UNLIMITED_USES) + .build(); + 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.action.DialogAction.customClick(sharedCallback, sharedOptions) ); io.papermc.paper.registry.data.dialog.ActionButton denyBtn = @@ -503,17 +509,7 @@ public class CustomScreenManager implements Listener { 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.action.DialogAction.customClick(sharedCallback, sharedOptions) ); io.papermc.paper.registry.data.dialog.type.ConfirmationType type = @@ -739,7 +735,8 @@ public class CustomScreenManager implements Listener { } catch (Exception ex) { plugin.getLogger().warning("[自定义屏幕] 删号失败: " + ex.getMessage()); } - p.kick(Component.text("您已拒签用户协议,账号已被删除。如有疑问请联系管理员。")); + // ★ 125 续9:del 动作 = 删号 + 踢出双动作(先删 login.db 记录使必须重新注册,再踢出服务器) + p.kick(Component.text("您已拒签用户协议,账号已被删除并被踢出服务器,需重新注册后方可再次进入。如有疑问请联系管理员。")); break; case "kick": p.kick(Component.text("您已拒签用户协议,已被踢出服务器。如有疑问请联系管理员。"));