第125批续9: Dialog 拒签/签收 action 彻底修复(删号+踢出双动作 + 同意不再误触发拒签)
Auto Release / build (push) Successful in 2m54s
Auto Release / build (push) Successful in 2m54s
根因:125 续8 的两个独立 customClick 回调在 Paper 26.2 的 ConfirmationType 里 因 yes/no 按钮协议层 key 冲突,点「同意」误触发拒签回调 → executeDenyAction → kick。 视频 13.25.45 坐实(1:21 起 3 次踢出,前 2 次拒签正常,第 3 次同意被踢出)。 修复: ① 两个按钮共用一个 customClick 回调(避免 key 冲突),回调里通过「签名是否匹配玩家名」 推断意图:签名==玩家名 → 签收(handleAccept 落盘回执单);签名空/!=玩家名 → 拒签(confirmDeny)。 即使 Paper 把 yes 点击路由到 reject 回调,签名匹配时仍自动转签收,杜绝「同意被踢出」。 ② Options.uses(UNLIMITED_USES)(旧默认 uses=1 单次使用,多次点击后 callback 失效)。 ③ 拒签 del 分支 kick 文案升级为「账号已被删除并被踢出服务器,需重新注册」双动作描述 (先 db.deleteUser 删 login.db users 表记录,再 kick 踢出,玩家重进服显示「尚未登录」需重新注册)。
This commit is contained in:
@@ -471,31 +471,37 @@ public class CustomScreenManager implements Listener {
|
|||||||
// ★ 125 续8:两个按钮都挂 DialogAction.customClick 回调(旧代码第4参传 null → 按钮点击只关弹窗不执行任何 Java 代码,
|
// ★ 125 续8:两个按钮都挂 DialogAction.customClick 回调(旧代码第4参传 null → 按钮点击只关弹窗不执行任何 Java 代码,
|
||||||
// 这是「点拒签/签收都只是关屏幕、action 没执行」的根因)。回调里 audience=点按钮的玩家,
|
// 这是「点拒签/签收都只是关屏幕、action 没执行」的根因)。回调里 audience=点按钮的玩家,
|
||||||
// 响应数据(DialogResponseView)含 DialogInput 的 key-value(signature 等),可判断 yes/no。
|
// 响应数据(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 acceptBtn =
|
||||||
io.papermc.paper.registry.data.dialog.ActionButton.create(
|
io.papermc.paper.registry.data.dialog.ActionButton.create(
|
||||||
Component.text("§a§l✔ 签收"),
|
Component.text("§a§l✔ 签收"),
|
||||||
Component.text("确认签收用户协议"),
|
Component.text("确认签收用户协议"),
|
||||||
200,
|
200,
|
||||||
io.papermc.paper.registry.data.dialog.action.DialogAction.customClick(
|
io.papermc.paper.registry.data.dialog.action.DialogAction.customClick(sharedCallback, sharedOptions)
|
||||||
(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 denyBtn =
|
||||||
@@ -503,17 +509,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
Component.text("§c§l✘ 拒签"),
|
Component.text("§c§l✘ 拒签"),
|
||||||
Component.text("执行 " + ps.actions.denyAction + " 动作"),
|
Component.text("执行 " + ps.actions.denyAction + " 动作"),
|
||||||
200,
|
200,
|
||||||
io.papermc.paper.registry.data.dialog.action.DialogAction.customClick(
|
io.papermc.paper.registry.data.dialog.action.DialogAction.customClick(sharedCallback, sharedOptions)
|
||||||
(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.ConfirmationType type =
|
||||||
@@ -739,7 +735,8 @@ public class CustomScreenManager implements Listener {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLogger().warning("[自定义屏幕] 删号失败: " + ex.getMessage());
|
plugin.getLogger().warning("[自定义屏幕] 删号失败: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
p.kick(Component.text("您已拒签用户协议,账号已被删除。如有疑问请联系管理员。"));
|
// ★ 125 续9:del 动作 = 删号 + 踢出双动作(先删 login.db 记录使必须重新注册,再踢出服务器)
|
||||||
|
p.kick(Component.text("您已拒签用户协议,账号已被删除并被踢出服务器,需重新注册后方可再次进入。如有疑问请联系管理员。"));
|
||||||
break;
|
break;
|
||||||
case "kick":
|
case "kick":
|
||||||
p.kick(Component.text("您已拒签用户协议,已被踢出服务器。如有疑问请联系管理员。"));
|
p.kick(Component.text("您已拒签用户协议,已被踢出服务器。如有疑问请联系管理员。"));
|
||||||
|
|||||||
Reference in New Issue
Block a user