125续15l-7l: 成书limit 150→120(150仍劈字,UI一屏~130字保守不劈)+拒签Dialog二次重弹失败自动handleDenyCommand送客(旧版只提示手敲=拒签失效)

This commit is contained in:
youpaishidifu
2026-11-22 15:15:06 +08:00
parent fcacd4ee4c
commit 493591c4b4
@@ -382,17 +382,15 @@ public class CustomScreenManager implements Listener {
java.util.List<String> pages = new java.util.ArrayList<>();
// ★ 15l-7j 封页补肉:正文前 ~150 字进封页,但必须在语义边界(。!?;\n)处切,
// ★ 15l-7j 封页补肉:正文前 ~120 字进封页,但必须在语义边界(。!?;\n)处切,
// 残句续下一页(与正文分页同一套 findSemanticCut 切法)。
// ★ 15l-7l 修复:limit 改回 150(与 15l-17 对齐)——MC 成书 UI 每屏竖排实际容 ~155 字,
// 15l-7k 把 limit 放宽到 400 是错误诊断(误以为 UI 能容 400 字),导致每页 411-420 字
// 被 UI 视口裁掉后半(截图实证:第2页 Java 侧 414 字完整,UI 只显示前 ~155 字,
// 「玩家应尊重…外挂、刷屏、刷数据」被裁)。150 字 + 语义切点(。!?;)+ 残句续下一页,
// 每页刚好一屏 UI 容量,不裁不丢。
// ★ 15l-7l 修复:limit 150→120(15l-7k 错改 400 被 15l-17 修回 150,但截图实证
// 150 仍偏大——第2页「使用」被劈、第3页「法」被劈,UI 一屏竖排实际容 ~130 字)。
// 120 字 + 语义切点(。!?;)+ 残句续下一页,每页保守不劈字。
// ★ 15l-7k 的「投票规则详见第六章第3节;」分号容差需求,靠 findSemanticCut 的
// 容差 limit+20=170 仍能满足(分号若落在 150~170 之间仍纳入切点)。
// 容差 limit+20=140 仍能满足(分号若落在 120~140 之间仍纳入切点)。
if (!body.isEmpty()) {
int cut = findSemanticCut(body, 150);
int cut = findSemanticCut(body, 120);
pages.add(body.substring(0, cut));
body = body.substring(cut);
}
@@ -409,10 +407,10 @@ public class CustomScreenManager implements Listener {
// 当前页为空:直接开始新段落
if (page.length() == 0) {
if (p.length() > 150) {
if (p.length() > 120) {
java.util.List<String> sentences = splitSentences(p);
for (String s : sentences) {
if (page.length() + s.length() + 1 > 150 && page.length() > 0) {
if (page.length() + s.length() + 1 > 120 && page.length() > 0) {
pages.add(page.toString().trim());
page = new StringBuilder();
}
@@ -425,14 +423,14 @@ public class CustomScreenManager implements Listener {
}
// 当前页已有内容:判断段落是否能整段放入
if (page.length() + p.length() + 1 <= 150) {
if (page.length() + p.length() + 1 <= 120) {
page.append("\n").append(p);
continue;
}
// 整段放不进:在「当前页 + 段落」里找语义边界截断
String candidate = page.toString() + "\n" + p;
int cut = findSemanticCut(candidate, 150);
int cut = findSemanticCut(candidate, 120);
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
String firstHalf = candidate.substring(0, cut);
String secondHalf = candidate.substring(cut);
@@ -443,8 +441,8 @@ public class CustomScreenManager implements Listener {
page = new StringBuilder(secondHalf);
// 若剩余段仍超页,继续按语义截断或按句拆
while (page.length() > 150) {
int nextCut = findSemanticCut(page.toString(), 150);
while (page.length() > 120) {
int nextCut = findSemanticCut(page.toString(), 120);
String chunk = page.substring(0, nextCut);
String remain = page.substring(nextCut);
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
@@ -465,7 +463,7 @@ public class CustomScreenManager implements Listener {
if (pages.size() > 2) {
String last = pages.get(pages.size() - 1);
String prev = pages.get(pages.size() - 2);
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 150) {
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 120) {
pages.set(pages.size() - 2, prev + "\n" + last);
pages.remove(pages.size() - 1);
}
@@ -1021,15 +1019,23 @@ public class CustomScreenManager implements Listener {
p.showDialog(dialog);
plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 拒签二次确认 Dialog 已弹出");
} catch (Exception ex) {
plugin.getLogger().warning("[自定义屏幕] 拒签确认 Dialog 弹出失败: " + ex.getMessage() + ",3 秒后重弹一次,仍失败则走 /sdf1_login deny 直接拒签。");
// ★ 125 续15j 人性化兜底:自动延迟 3 秒重弹一次(Geyser/Dialog API 偶发失败)
plugin.getLogger().warning("[自定义屏幕] 拒签确认 Dialog 弹出失败: " + ex.getMessage() + ",3 秒后重弹一次,仍失败则自动拒签送客。");
// ★ 15l-7m 兜底加固(用户定调"真正拒签协议也没送客"):
// 旧版二次重弹失败只提示玩家手敲 /sdf1_login deny——但 Dialog pause 持续失败时
// 玩家也敲不了命令(界面被 Dialog 占用 / Geyser 通道断),拒签形同虚设。
// 改:二次重弹仍失败 → 直接 confirmDeny 走 executeDenyAction 自动送客(del 删号/kick),
// 玩家不敲命令也完成拒签闭环(对齐 15e「第一道闸就干活」铁律)。
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
if (!p.isOnline()) return;
PendingSign cur = pendingSigs.get(p.getUniqueId());
if (cur == null) return; // 玩家已表态,无需再送客
try {
showDenyConfirmDialog(p, ps);
showDenyConfirmDialog(p, cur);
} catch (Exception ex2) {
plugin.getLogger().warning("[自定义屏幕] " + p.getName() + " 拒签 Dialog 二次重弹仍失败,兜底走 /sdf1_login deny 直接拒签(跳过二次确认)");
p.sendMessage(Component.text("§c拒签确认 Dialog 弹出失败。直接输入 §l/sdf1_login deny§r 拒签(跳过二次确认,直接执行 " + ps.actions.denyAction + " 动作),或 §l/sdf1_login cancel deny§r 取消。"));
plugin.getLogger().warning("[自定义屏幕] " + p.getName() + " 拒签 Dialog 二次重弹仍失败,自动拒签送客(执行 " + cur.actions.denyAction + " 动作)");
p.sendMessage(Component.text("§c拒签确认 Dialog 弹出失败,已自动为您执行拒签(" + cur.actions.denyAction + ")。"));
// 自动调 handleDenyCommand(confirmDeny → executeDenyAction → del 删号/kick 送客)
handleDenyCommand(p, new String[0]);
}
}, 60L); // 3 秒
}