三个修复: 1. 基岩版走 GUI 拒签二次确认(showDenyConfirmGUI),不动 Dialog API。 2. Java 版 showDenyConfirmDialog 失败兜底:3 秒后自动重弹一次(Geyser/Dialog API 偶发失败), 仍失败 → 提示"直接输入 /sdf1_login deny 拒签(跳过二次确认,直接执行动作)", 或 /sdf1_login cancel deny 取消(后悔继续签署)。新增 /sdf1_login cancel deny 命令分支。 旧兜底文案让玩家手敲 /sdf1_login confirm deny <长标题>,改人性化文案。 3. CLI 改领地 CLI 范式(对齐 MenuManager): - cliActive 从 Set<UUID> 改 Set<String>(按玩家名,与 MenuManager.chatWait 一致) - onChat 改成普通方法(不再 @EventHandler),由 Main.onChat 按 isViewing 调 - 聊天输入只拦截 数字/精确协议名/prev/next/back/quit;其它普通聊天不 cancel(放行) - 新增 matchesSignedAgreement 判断消息是否精确匹配已签协议 key - 新增 isViewing 判断玩家是否处于 CLI 查看模式(供 Main.onChat 调用) 截图铁证:旧 CLI 把"come on baby"/"?"/"不是保护吗?"全当协议名吞掉, 新 CLI 只拦精确匹配,普通聊天放行。 编译 rc=0,jar 0c7a5253。
This commit is contained in:
@@ -740,6 +740,11 @@ public class CustomScreenManager implements Listener {
|
|||||||
* ★ 125 续13:拒签二次确认 Dialog(讲清利害关系,可后悔退回)。
|
* ★ 125 续13:拒签二次确认 Dialog(讲清利害关系,可后悔退回)。
|
||||||
* 两按钮:「确认拒签」(走 executeDenyAction)/「后悔,继续签署」(退回主 Dialog 重新签署)。
|
* 两按钮:「确认拒签」(走 executeDenyAction)/「后悔,继续签署」(退回主 Dialog 重新签署)。
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* 拒签二次确认 Dialog(Java 版用,基岩版走 showDenyConfirmGUI)。
|
||||||
|
* 125 续15j 人性化兜底:Dialog 弹出失败时,不再让玩家手敲 /sdf1_login confirm deny <长标题>,
|
||||||
|
* 改成 ① 自动延迟 3 秒重弹一次(Geyser 偶发失败);② 仍失败 → 提示"用 /sdf1_login deny 直接拒签(跳过二次确认)"。
|
||||||
|
*/
|
||||||
private void showDenyConfirmDialog(Player p, PendingSign ps) {
|
private void showDenyConfirmDialog(Player p, PendingSign ps) {
|
||||||
try {
|
try {
|
||||||
String consequences = ps.actions.denyAction.equalsIgnoreCase("del")
|
String consequences = ps.actions.denyAction.equalsIgnoreCase("del")
|
||||||
@@ -750,7 +755,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
io.papermc.paper.registry.data.dialog.DialogBase.builder(
|
io.papermc.paper.registry.data.dialog.DialogBase.builder(
|
||||||
Component.text("【拒签确认】" + new File(ps.pendingFile).getName())
|
Component.text("【拒签确认】" + new File(ps.pendingFile).getName())
|
||||||
)
|
)
|
||||||
.canCloseWithEscape(true) // 允许 ESC 关闭(= 后悔,不拒签)
|
.canCloseWithEscape(true)
|
||||||
.afterAction(io.papermc.paper.registry.data.dialog.DialogBase.DialogAfterAction.NONE)
|
.afterAction(io.papermc.paper.registry.data.dialog.DialogBase.DialogAfterAction.NONE)
|
||||||
.body(java.util.List.of(
|
.body(java.util.List.of(
|
||||||
io.papermc.paper.registry.data.dialog.body.DialogBody.plainMessage(
|
io.papermc.paper.registry.data.dialog.body.DialogBody.plainMessage(
|
||||||
@@ -781,7 +786,6 @@ public class CustomScreenManager implements Listener {
|
|||||||
if (!(audience instanceof Player player)) return;
|
if (!(audience instanceof Player player)) return;
|
||||||
PendingSign cur = pendingSigs.get(player.getUniqueId());
|
PendingSign cur = pendingSigs.get(player.getUniqueId());
|
||||||
if (cur == null) return;
|
if (cur == null) return;
|
||||||
// 二次确认通过 → 真正执行拒签动作
|
|
||||||
confirmDeny(player, new File(cur.pendingFile).getName(), "");
|
confirmDeny(player, new File(cur.pendingFile).getName(), "");
|
||||||
},
|
},
|
||||||
denyConfirmOpts
|
denyConfirmOpts
|
||||||
@@ -798,7 +802,6 @@ public class CustomScreenManager implements Listener {
|
|||||||
if (!(audience instanceof Player player)) return;
|
if (!(audience instanceof Player player)) return;
|
||||||
PendingSign cur = pendingSigs.get(player.getUniqueId());
|
PendingSign cur = pendingSigs.get(player.getUniqueId());
|
||||||
if (cur == null) return;
|
if (cur == null) return;
|
||||||
// 后悔 → 退回主 Dialog(重新弹出待签收屏)
|
|
||||||
player.sendMessage(Component.text("§6已退回,请重新签署用户协议"));
|
player.sendMessage(Component.text("§6已退回,请重新签署用户协议"));
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||||
if (player.isOnline() && pendingSigs.containsKey(player.getUniqueId())) {
|
if (player.isOnline() && pendingSigs.containsKey(player.getUniqueId())) {
|
||||||
@@ -819,9 +822,17 @@ public class CustomScreenManager implements Listener {
|
|||||||
p.showDialog(dialog);
|
p.showDialog(dialog);
|
||||||
plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 拒签二次确认 Dialog 已弹出");
|
plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 拒签二次确认 Dialog 已弹出");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLogger().warning("[自定义屏幕] 拒签确认 Dialog 弹出失败: " + ex.getMessage());
|
plugin.getLogger().warning("[自定义屏幕] 拒签确认 Dialog 弹出失败: " + ex.getMessage() + ",3 秒后重弹一次,仍失败则走 /sdf1_login deny 直接拒签。");
|
||||||
p.sendMessage(Component.text("§c拒签确认 Dialog 弹出失败,请输入 /sdf1_login confirm deny "
|
// ★ 125 续15j 人性化兜底:自动延迟 3 秒重弹一次(Geyser/Dialog API 偶发失败)
|
||||||
+ new File(ps.pendingFile).getName() + " 确认拒签"));
|
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
if (!p.isOnline()) return;
|
||||||
|
try {
|
||||||
|
showDenyConfirmDialog(p, ps);
|
||||||
|
} 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 取消。"));
|
||||||
|
}
|
||||||
|
}, 60L); // 3 秒
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6866,6 +6866,20 @@ public class Main extends JavaPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 125 续15j 领地 CLI 范式:/rules 聊天输入(数字/协议名/prev/next/back/quit)
|
||||||
|
// 与 MenuManager 对齐:玩家处于 /rules CLI 查看模式时,拦截数字/协议名/翻页命令;
|
||||||
|
// 其它普通聊天不 cancel(rulesCLIManager.onChat 内部判断)。
|
||||||
|
if (rulesCLIManager != null && rulesCLIManager.isViewing(p.getName())) {
|
||||||
|
String low = msg.trim().toLowerCase();
|
||||||
|
boolean isRulesCmd = low.equals("quit") || low.equals("q") || low.equals("prev")
|
||||||
|
|| low.equals("next") || low.equals("back") || msg.trim().matches("\\d+");
|
||||||
|
if (isRulesCmd || rulesCLIManager.matchesSignedAgreement(p.getName(), msg.trim())) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
rulesCLIManager.onChat(p, msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 聊天输入流程(改密码/绑邮箱等) =====
|
// ===== 聊天输入流程(改密码/绑邮箱等) =====
|
||||||
if (chatInput.isInFlow(p)) {
|
if (chatInput.isInFlow(p)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@@ -9323,6 +9337,13 @@ public class Main extends JavaPlugin
|
|||||||
customScreenManager.handleConfirmDeny(p, confirmArgs);
|
customScreenManager.handleConfirmDeny(p, confirmArgs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// ★ 125 续15j:/sdf1_login cancel deny 取消拒签(后悔继续签署)
|
||||||
|
if (args.length >= 2 && args[0].equalsIgnoreCase("cancel") && args[1].equalsIgnoreCase("deny")) {
|
||||||
|
if (!(sender instanceof Player)) { sender.sendMessage("§c仅限玩家使用"); return true; }
|
||||||
|
Player p = (Player) sender;
|
||||||
|
customScreenManager.handleCancelDeny(p);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (args.length >= 1 && args[0].equalsIgnoreCase("cancel")) {
|
if (args.length >= 1 && args[0].equalsIgnoreCase("cancel")) {
|
||||||
if (!(sender instanceof Player)) { sender.sendMessage("§c仅限玩家使用"); return true; }
|
if (!(sender instanceof Player)) { sender.sendMessage("§c仅限玩家使用"); return true; }
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public class RulesCLIManager implements Listener {
|
|||||||
private final Map<UUID, String> viewing = new ConcurrentHashMap<>();
|
private final Map<UUID, String> viewing = new ConcurrentHashMap<>();
|
||||||
// 每个玩家当前页码
|
// 每个玩家当前页码
|
||||||
private final Map<UUID, Integer> currentPage = new ConcurrentHashMap<>();
|
private final Map<UUID, Integer> currentPage = new ConcurrentHashMap<>();
|
||||||
// CLI 会话中允许"聊天输入"的窗口
|
// CLI 会话中允许"聊天输入"的窗口(按玩家名,与 MenuManager.chatWait 对齐)
|
||||||
private final Set<UUID> cliActive = ConcurrentHashMap.newKeySet();
|
private final Set<String> cliActive = ConcurrentHashMap.newKeySet();
|
||||||
// 每页字数
|
// 每页字数
|
||||||
private static final int PAGE_SIZE = 150;
|
private static final int PAGE_SIZE = 150;
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ public class RulesCLIManager implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sub.equals("quit") || sub.equals("q")) {
|
if (sub.equals("quit") || sub.equals("q")) {
|
||||||
cliActive.remove(p.getUniqueId());
|
cliActive.remove(p.getName());
|
||||||
p.sendMessage(Component.text("§7已退出协议查看模式。"));
|
p.sendMessage(Component.text("§7已退出协议查看模式。"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ public class RulesCLIManager implements Listener {
|
|||||||
|
|
||||||
// 无参 → 进入 CLI 列表页
|
// 无参 → 进入 CLI 列表页
|
||||||
if (args.length == 0 || sub.isEmpty()) {
|
if (args.length == 0 || sub.isEmpty()) {
|
||||||
cliActive.add(p.getUniqueId());
|
cliActive.add(p.getName());
|
||||||
showList(p);
|
showList(p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ public class RulesCLIManager implements Listener {
|
|||||||
int pg = Math.max(1, Math.min(page, pages.size()));
|
int pg = Math.max(1, Math.min(page, pages.size()));
|
||||||
viewing.put(p.getUniqueId(), key);
|
viewing.put(p.getUniqueId(), key);
|
||||||
currentPage.put(p.getUniqueId(), pg);
|
currentPage.put(p.getUniqueId(), pg);
|
||||||
cliActive.add(p.getUniqueId());
|
cliActive.add(p.getName());
|
||||||
renderPage(p, key, pages, pg);
|
renderPage(p, key, pages, pg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,63 +300,87 @@ public class RulesCLIManager implements Listener {
|
|||||||
p.sendMessage(Component.text("§7prev 上一页 | next 下一页 | back 返回列表 | quit 退出 | /rules gui 开 GUI"));
|
p.sendMessage(Component.text("§7prev 上一页 | next 下一页 | back 返回列表 | quit 退出 | /rules gui 开 GUI"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 聊天输入拦截(CLI 模式下支持"协议名/数字"快速跳) ====================
|
/**
|
||||||
|
* ★ 125 续15j 领地 CLI 范式:/rules 默认走 CLI 列表页,聊天输入 数字/协议名/prev/next/back/quit。
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
* 与 MenuManager 对齐:
|
||||||
public void onChat(org.bukkit.event.player.AsyncPlayerChatEvent e) {
|
* - 进入 CLI 时把玩家加入 cliActive(Set<String> 按玩家名,与 MenuManager 一致)
|
||||||
if (!cliActive.contains(e.getPlayer().getUniqueId())) return;
|
* - 聊天输入只拦截"精确等于已签协议 key、数字 1~N、prev/next/back/quit",其它聊天放行
|
||||||
String msg = e.getMessage().trim();
|
* - 普通聊天不 cancel,只提示 /rules 查看方式(不吞消息)
|
||||||
|
* @param p 玩家
|
||||||
|
* @param msg 聊天消息(已 trim)
|
||||||
|
*/
|
||||||
|
public void onChat(Player p, String msg) {
|
||||||
|
String name = p.getName();
|
||||||
|
if (!cliActive.contains(name)) return;
|
||||||
|
msg = msg.trim();
|
||||||
if (msg.isEmpty()) return;
|
if (msg.isEmpty()) return;
|
||||||
Player p = e.getPlayer();
|
|
||||||
String low = msg.toLowerCase();
|
String low = msg.toLowerCase();
|
||||||
|
|
||||||
|
// quit / q → 退出 CLI
|
||||||
if (low.equals("quit") || low.equals("q")) {
|
if (low.equals("quit") || low.equals("q")) {
|
||||||
cliActive.remove(p.getUniqueId());
|
cliActive.remove(name);
|
||||||
p.sendMessage(Component.text("§7已退出协议查看模式。"));
|
p.sendMessage(Component.text("§7已退出协议查看模式。"));
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// prev / next / back
|
||||||
if (low.equals("prev")) {
|
if (low.equals("prev")) {
|
||||||
movePage(p, -1);
|
movePage(p, -1);
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (low.equals("next")) {
|
if (low.equals("next")) {
|
||||||
movePage(p, +1);
|
movePage(p, +1);
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (low.equals("back")) {
|
if (low.equals("back")) {
|
||||||
closeViewer(p);
|
closeViewer(p);
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 数字 1~N → 跳协议(拦截)
|
// 数字 1~N → 跳协议
|
||||||
if (msg.matches("\\d+")) {
|
if (msg.matches("\\d+")) {
|
||||||
openAgreement(p, msg, 1);
|
openAgreement(p, msg, 1);
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ★ 125 续15i 修 CLI 卡死:只拦截"已签协议名精确匹配"的聊天,其它聊天放行。
|
// 精确等于已签协议 key → 跳协议
|
||||||
// 旧逻辑把任意聊天("come on baby"、"?"、"不是保护吗?")都当协议名吞掉(截图铁证)。
|
LinkedHashMap<String, String> signed = listSignedAgreements(name);
|
||||||
// 现在:消息精确等于某已签协议 key,或匹配 "公告:xxx"/"xxx.md" → 拦截跳协议;否则放行。
|
|
||||||
LinkedHashMap<String, String> signed = listSignedAgreements(p.getName());
|
|
||||||
boolean isKnown = false;
|
boolean isKnown = false;
|
||||||
for (String k : signed.keySet()) {
|
for (String k : signed.keySet()) {
|
||||||
if (msg.equalsIgnoreCase(k) || msg.equalsIgnoreCase(k.replaceAll("^公告:", ""))
|
if (msg.equalsIgnoreCase(k) || msg.equals(k + ".md") || msg.equals("公告:" + k)) {
|
||||||
|| msg.equals(k) || msg.equals(k + ".md") || msg.equals("公告:" + k)) {
|
|
||||||
isKnown = true;
|
isKnown = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isKnown) {
|
if (isKnown) {
|
||||||
openAgreement(p, msg, 1);
|
openAgreement(p, msg, 1);
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 未知聊天 → 放行(不拦截),提示可输入协议名/数字调出原文
|
// 未知聊天 → 放行(不 cancel),只提示 /rules 查看方式
|
||||||
p.sendMessage(Component.text("§7(/rules 提示:输入 1~" + signed.size() + " 或协议名调出原文,quit 退出查看模式,普通聊天不受影响)"));
|
p.sendMessage(Component.text("§7(/rules 提示:输入 1~" + signed.size() + " 或协议名调出原文,quit 退出查看模式,普通聊天不受影响)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断消息是否精确匹配该玩家已签的某个协议 key(供 Main.onChat 判断是否 cancel 聊天)。
|
||||||
|
* @param name 玩家名
|
||||||
|
* @param msg 聊天消息(已 trim)
|
||||||
|
* @return true = 精确匹配(应拦截),false = 普通聊天(应放行)
|
||||||
|
*/
|
||||||
|
public boolean matchesSignedAgreement(String name, String msg) {
|
||||||
|
if (msg == null || msg.isEmpty()) return false;
|
||||||
|
LinkedHashMap<String, String> signed = listSignedAgreements(name);
|
||||||
|
for (String k : signed.keySet()) {
|
||||||
|
if (msg.equalsIgnoreCase(k) || msg.equals(k + ".md") || msg.equals("公告:" + k)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断玩家是否处于 CLI 查看模式(供 Main.onChat 调用,与 MenuManager.isEditing 对齐)。
|
||||||
|
*/
|
||||||
|
public boolean isViewing(String name) {
|
||||||
|
return cliActive.contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
/** 分页:每页最多 pageSize 字,按行切分(一行不跨页) */
|
/** 分页:每页最多 pageSize 字,按行切分(一行不跨页) */
|
||||||
private List<String> paginate(String content, int pageSize) {
|
private List<String> paginate(String content, int pageSize) {
|
||||||
List<String> pages = new ArrayList<>();
|
List<String> pages = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user