- ACK_DIR 统一为「签收回执」(去掉多出的「回」字),与资源文件/生产服对齐 - findPendingFiles 拆分为 findGlobalPendingFiles(用户协议:所有.md对全服生效) 和 findPlayerPendingFiles(公告:按玩家名.标题.md匹配) - 全局协议签收回执 = 玩家名.md(一个玩家一个文件) - 玩家通知签收回执 = 原文件名 - PendingSign 增加 pendingFile(绝对路径)+ ackFileName(回执文件名) - 新增日志:无待签收/已签收/待签收/签收成功 全链路可追踪
This commit is contained in:
@@ -31,11 +31,12 @@ import java.util.regex.Pattern;
|
|||||||
* 用户协议 & 公告送达(第125批)
|
* 用户协议 & 公告送达(第125批)
|
||||||
*
|
*
|
||||||
* 核心功能:
|
* 核心功能:
|
||||||
* - 玩家上线时扫描「用户协议/签收回回执/」和「公告/自定义屏幕/签收回回执/」目录
|
* - 玩家上线时扫描「用户协议/签收回执/」和「公告/自定义屏幕/签收回执/」目录
|
||||||
* - 若存在未签收的通知(玩家.标题.md 存在 且 签收回回执下没有同名文件),弹出自定义屏幕
|
* - 用户协议:所有 .md 对全服玩家生效(全局协议),签收回执 = 玩家名.md
|
||||||
* - 自定义屏幕:2 按钮(签收/拒签)+ 1 输入框(签名 = 玩家ID)
|
* - 公告:按 玩家名.标题.md 匹配,签收回执 = 原文件名
|
||||||
|
* - GUI:2 按钮(签收/拒签)+ 书与笔(完整协议塞入书页),死循环弹窗强制表态
|
||||||
* - 签收 → 落盘回执单;拒签 → 二次弹窗确认 → 执行拒签动作(del/rm/kick/ban/banip)
|
* - 签收 → 落盘回执单;拒签 → 二次弹窗确认 → 执行拒签动作(del/rm/kick/ban/banip)
|
||||||
* - Geyser 基岩版玩家 → GUI 确认(简易聊天命令);Java 版 → 自定义屏幕
|
* - Geyser 基岩版玩家 → GUI(书与笔);Java 版 → GUI(统一逻辑)
|
||||||
*/
|
*/
|
||||||
public class CustomScreenManager implements Listener {
|
public class CustomScreenManager implements Listener {
|
||||||
|
|
||||||
@@ -46,8 +47,8 @@ public class CustomScreenManager implements Listener {
|
|||||||
// 目录常量
|
// 目录常量
|
||||||
private static final String AGREEMENT_DIR = "用户协议";
|
private static final String AGREEMENT_DIR = "用户协议";
|
||||||
private static final String NOTIFICATION_DIR = "公告/自定义屏幕";
|
private static final String NOTIFICATION_DIR = "公告/自定义屏幕";
|
||||||
private static final String ACK_DIR_AGREEMENT = AGREEMENT_DIR + "/签收回回执";
|
private static final String ACK_DIR_AGREEMENT = AGREEMENT_DIR + "/签收回执";
|
||||||
private static final String ACK_DIR_NOTIFICATION = NOTIFICATION_DIR + "/签收回回执";
|
private static final String ACK_DIR_NOTIFICATION = NOTIFICATION_DIR + "/签收回执";
|
||||||
|
|
||||||
// 正则:玩家.标题.md
|
// 正则:玩家.标题.md
|
||||||
private static final Pattern FILENAME_PATTERN = Pattern.compile("^(.+)\\.(.+\\.md)$");
|
private static final Pattern FILENAME_PATTERN = Pattern.compile("^(.+)\\.(.+\\.md)$");
|
||||||
@@ -77,41 +78,55 @@ public class CustomScreenManager implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查玩家是否有未签收的通知/协议,有则弹出自定义屏幕。
|
* 检查玩家是否有未签收的通知/协议,有则弹出自定义屏幕。
|
||||||
* 基岩版(Geyser)→ 聊天命令确认;Java 版 → 自定义屏幕。
|
* 基岩版(Geyser)→ GUI 确认;Java 版 → GUI 确认(统一逻辑,死循环弹窗)。
|
||||||
|
*
|
||||||
|
* 用户协议目录:所有 .md 文件对全服玩家生效(全局协议),签收回执 = 玩家名.md。
|
||||||
|
* 公告/自定义屏幕目录:按 玩家名.标题.md 匹配,签收回执 = 玩家名.标题.md。
|
||||||
*/
|
*/
|
||||||
private void checkAndShowPending(Player p) {
|
private void checkAndShowPending(Player p) {
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
|
|
||||||
// 1. 扫描用户协议目录
|
// 1. 扫描用户协议目录(全局协议:所有 .md 对所有玩家生效)
|
||||||
File agrDir = new File(plugin.getDataFolder(), AGREEMENT_DIR);
|
File agrDir = new File(plugin.getDataFolder(), AGREEMENT_DIR);
|
||||||
File ackDirAgr = new File(plugin.getDataFolder(), ACK_DIR_AGREEMENT);
|
File ackDirAgr = new File(plugin.getDataFolder(), ACK_DIR_AGREEMENT);
|
||||||
ensureDir(ackDirAgr);
|
ensureDir(ackDirAgr);
|
||||||
|
|
||||||
// 2. 扫描公告/自定义屏幕目录
|
// 2. 扫描公告/自定义屏幕目录(按玩家名匹配)
|
||||||
File notiDir = new File(plugin.getDataFolder(), NOTIFICATION_DIR);
|
File notiDir = new File(plugin.getDataFolder(), NOTIFICATION_DIR);
|
||||||
File ackDirNoti = new File(plugin.getDataFolder(), ACK_DIR_NOTIFICATION);
|
File ackDirNoti = new File(plugin.getDataFolder(), ACK_DIR_NOTIFICATION);
|
||||||
ensureDir(ackDirNoti);
|
ensureDir(ackDirNoti);
|
||||||
|
|
||||||
// 找该玩家所有待签收文件(协议 + 通知)
|
// 找该玩家所有待签收文件
|
||||||
String[] agrFiles = findPendingFiles(agrDir, name);
|
String[] agrFiles = findGlobalPendingFiles(agrDir, name);
|
||||||
String[] notiFiles = findPendingFiles(notiDir, name);
|
String[] notiFiles = findPlayerPendingFiles(notiDir, name);
|
||||||
|
|
||||||
if (agrFiles.length == 0 && notiFiles.length == 0) return; // 无待签收
|
if (agrFiles.length == 0 && notiFiles.length == 0) {
|
||||||
|
plugin.getLogger().info("[自定义屏幕] " + name + " 无待签收(全局协议=" + agrFiles.length + " 玩家通知=" + notiFiles.length + ")");
|
||||||
|
return; // 无待签收
|
||||||
|
}
|
||||||
|
|
||||||
// 合并所有待签收文件
|
// 合并所有待签收文件
|
||||||
String[] all = new String[agrFiles.length + notiFiles.length];
|
String[] all = new String[agrFiles.length + notiFiles.length];
|
||||||
System.arraycopy(agrFiles, 0, all, 0, agrFiles.length);
|
System.arraycopy(agrFiles, 0, all, 0, agrFiles.length);
|
||||||
System.arraycopy(notiFiles, 0, all, agrFiles.length, notiFiles.length);
|
System.arraycopy(notiFiles, 0, all, agrFiles.length, notiFiles.length);
|
||||||
all[all.length - 1] = all[all.length - 1]; // 保持引用
|
|
||||||
|
|
||||||
// 取第一个未签收的作为主弹窗(一次只弹一个)
|
// 取第一个未签收的作为主弹窗(一次只弹一个)
|
||||||
String pendingFile = all[0];
|
String pendingFile = all[0];
|
||||||
String ackDir = pendingFile.startsWith(AGREEMENT_DIR) ? ACK_DIR_AGREEMENT : ACK_DIR_NOTIFICATION;
|
boolean isGlobal = pendingFile.contains(AGREEMENT_DIR);
|
||||||
|
String ackDir = isGlobal ? ACK_DIR_AGREEMENT : ACK_DIR_NOTIFICATION;
|
||||||
|
|
||||||
// 检查签收回执是否已存在(文件名匹配)
|
// 检查签收回执是否已存在
|
||||||
|
// 全局协议:签收回执文件名 = 玩家名.md
|
||||||
|
// 玩家通知:签收回执文件名 = 原文件名(玩家名.标题.md)
|
||||||
String fileName = new File(pendingFile).getName();
|
String fileName = new File(pendingFile).getName();
|
||||||
File ackFile = new File(new File(plugin.getDataFolder(), ackDir), fileName);
|
String ackFileName = isGlobal ? name + ".md" : fileName;
|
||||||
if (ackFile.exists() && ackFile.length() > 0) return; // 已签收
|
File ackFile = new File(new File(plugin.getDataFolder(), ackDir), ackFileName);
|
||||||
|
if (ackFile.exists() && ackFile.length() > 0) {
|
||||||
|
plugin.getLogger().info("[自定义屏幕] " + name + " 已签收 " + ackFileName + ",跳过弹窗");
|
||||||
|
return; // 已签收
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLogger().info("[自定义屏幕] " + name + " 待签收: " + pendingFile + " (ack=" + ackFileName + ")");
|
||||||
|
|
||||||
// 读取通知内容
|
// 读取通知内容
|
||||||
String content;
|
String content;
|
||||||
@@ -127,23 +142,45 @@ public class CustomScreenManager implements Listener {
|
|||||||
|
|
||||||
// 基岩版走 GUI(书与笔),Java 版也走 GUI(统一逻辑,死循环弹窗)
|
// 基岩版走 GUI(书与笔),Java 版也走 GUI(统一逻辑,死循环弹窗)
|
||||||
if (isBedrock(p)) {
|
if (isBedrock(p)) {
|
||||||
showBedrockSign(p, fileName, content, actions);
|
showBedrockSign(p, pendingFile, ackFileName, content, actions);
|
||||||
} else {
|
} else {
|
||||||
showCustomScreen(p, fileName, content, actions);
|
showCustomScreen(p, pendingFile, ackFileName, content, actions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在目录下找玩家的所有待签收文件({name}.*.md 且签收回执下没有同名文件)。
|
* 全局协议:目录下所有 .md 文件对所有玩家生效。
|
||||||
|
* 签收回执 = 玩家名.md(一个玩家一个文件)。
|
||||||
*/
|
*/
|
||||||
private String[] findPendingFiles(File dir, String playerName) {
|
private String[] findGlobalPendingFiles(File dir, String playerName) {
|
||||||
|
if (!dir.exists() || !dir.isDirectory()) return new String[0];
|
||||||
|
File[] files = dir.listFiles((d, n) -> n.endsWith(".md"));
|
||||||
|
if (files == null || files.length == 0) return new String[0];
|
||||||
|
|
||||||
|
File ackDir = new File(plugin.getDataFolder(), ACK_DIR_AGREEMENT);
|
||||||
|
if (!ackDir.exists()) ensureDir(ackDir);
|
||||||
|
|
||||||
|
java.util.List<String> pending = new java.util.ArrayList<>();
|
||||||
|
for (File f : files) {
|
||||||
|
String ackName = playerName + ".md"; // 全局协议:回执文件名 = 玩家名.md
|
||||||
|
File ackFile = new File(ackDir, ackName);
|
||||||
|
if (!ackFile.exists() || ackFile.length() == 0) {
|
||||||
|
pending.add(f.getAbsolutePath());
|
||||||
|
break; // 一个全局协议足够,不叠加
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pending.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家通知:按 {玩家名}.*.md 匹配,签收回执 = 原文件名。
|
||||||
|
*/
|
||||||
|
private String[] findPlayerPendingFiles(File dir, String playerName) {
|
||||||
if (!dir.exists() || !dir.isDirectory()) return new String[0];
|
if (!dir.exists() || !dir.isDirectory()) return new String[0];
|
||||||
File[] files = dir.listFiles((d, n) -> n.startsWith(playerName + ".") && n.endsWith(".md"));
|
File[] files = dir.listFiles((d, n) -> n.startsWith(playerName + ".") && n.endsWith(".md"));
|
||||||
if (files == null || files.length == 0) return new String[0];
|
if (files == null || files.length == 0) return new String[0];
|
||||||
|
|
||||||
// 签收回执目录
|
File ackDir = new File(plugin.getDataFolder(), ACK_DIR_NOTIFICATION);
|
||||||
String ackDirPath = (dir.getPath().contains(AGREEMENT_DIR)) ? ACK_DIR_AGREEMENT : ACK_DIR_NOTIFICATION;
|
|
||||||
File ackDir = new File(plugin.getDataFolder(), ackDirPath);
|
|
||||||
if (!ackDir.exists()) ensureDir(ackDir);
|
if (!ackDir.exists()) ensureDir(ackDir);
|
||||||
|
|
||||||
java.util.List<String> pending = new java.util.ArrayList<>();
|
java.util.List<String> pending = new java.util.ArrayList<>();
|
||||||
@@ -185,15 +222,15 @@ public class CustomScreenManager implements Listener {
|
|||||||
* 基岩版玩家:自定义 GUI 确认(书与笔完整协议 + 签收/拒签按钮)。
|
* 基岩版玩家:自定义 GUI 确认(书与笔完整协议 + 签收/拒签按钮)。
|
||||||
* 死循环弹窗:关闭即重弹,必须表态(签收或拒签)。
|
* 死循环弹窗:关闭即重弹,必须表态(签收或拒签)。
|
||||||
*/
|
*/
|
||||||
private void showBedrockSign(Player p, String fileName, String content, ActionConfig actions) {
|
private void showBedrockSign(Player p, String pendingFile, String ackFileName, String content, ActionConfig actions) {
|
||||||
PendingSign ps = new PendingSign(fileName, content, actions);
|
PendingSign ps = new PendingSign(pendingFile, ackFileName, content, actions);
|
||||||
pendingSigs.put(p.getUniqueId(), ps);
|
pendingSigs.put(p.getUniqueId(), ps);
|
||||||
|
|
||||||
// 创建一个 3 槽 GUI:slot0=书(完整协议)、slot1=签收、slot2=拒签
|
// 创建一个 3 槽 GUI:slot0=书(完整协议)、slot1=签收、slot2=拒签
|
||||||
org.bukkit.inventory.Inventory gui = Bukkit.createInventory(null, 3, "§6【待签收】" + new File(fileName).getName());
|
org.bukkit.inventory.Inventory gui = Bukkit.createInventory(null, 3, "§6【待签收】" + new File(pendingFile).getName());
|
||||||
|
|
||||||
// slot 0: 书与笔(完整协议内容)
|
// slot 0: 书与笔(完整协议内容)
|
||||||
ItemStack book = createBookItem(content, fileName);
|
ItemStack book = createBookItem(content, new File(pendingFile).getName());
|
||||||
gui.setItem(0, book);
|
gui.setItem(0, book);
|
||||||
|
|
||||||
// slot 1: 签收(绿)
|
// slot 1: 签收(绿)
|
||||||
@@ -270,9 +307,9 @@ public class CustomScreenManager implements Listener {
|
|||||||
if (!p.isOnline()) return;
|
if (!p.isOnline()) return;
|
||||||
if (pendingSigs.containsKey(p.getUniqueId())) {
|
if (pendingSigs.containsKey(p.getUniqueId())) {
|
||||||
if (isBedrock(p)) {
|
if (isBedrock(p)) {
|
||||||
showBedrockSign(p, ps.fileName, ps.content, ps.actions);
|
showBedrockSign(p, ps.pendingFile, ps.ackFileName, ps.content, ps.actions);
|
||||||
} else {
|
} else {
|
||||||
showCustomScreen(p, ps.fileName, ps.content, ps.actions);
|
showCustomScreen(p, ps.pendingFile, ps.ackFileName, ps.content, ps.actions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1L);
|
}, 1L);
|
||||||
@@ -374,7 +411,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
|
|
||||||
if (slot == 1 && clicked != null && clicked.getType() == Material.RED_STAINED_GLASS_PANE) {
|
if (slot == 1 && clicked != null && clicked.getType() == Material.RED_STAINED_GLASS_PANE) {
|
||||||
// 确认拒签
|
// 确认拒签
|
||||||
confirmDeny(p, new File(ps.fileName).getName(), draftSignatures.get(p.getUniqueId()));
|
confirmDeny(p, new File(ps.pendingFile).getName(), draftSignatures.get(p.getUniqueId()));
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
} else if (slot == 2 && clicked != null && clicked.getType() == Material.LIME_STAINED_GLASS_PANE) {
|
} else if (slot == 2 && clicked != null && clicked.getType() == Material.LIME_STAINED_GLASS_PANE) {
|
||||||
// 取消 → 恢复草稿
|
// 取消 → 恢复草稿
|
||||||
@@ -388,15 +425,15 @@ public class CustomScreenManager implements Listener {
|
|||||||
* 注:Paper 1.21+ 的 Dialog API 底层仍用数据包实现,为保持灵活性(动态内容),
|
* 注:Paper 1.21+ 的 Dialog API 底层仍用数据包实现,为保持灵活性(动态内容),
|
||||||
* 改用 Inventory GUI + 书与笔(完整协议塞入书页),死循环弹窗强制表态。
|
* 改用 Inventory GUI + 书与笔(完整协议塞入书页),死循环弹窗强制表态。
|
||||||
*/
|
*/
|
||||||
private void showCustomScreen(Player p, String fileName, String content, ActionConfig actions) {
|
private void showCustomScreen(Player p, String pendingFile, String ackFileName, String content, ActionConfig actions) {
|
||||||
PendingSign ps = new PendingSign(fileName, content, actions);
|
PendingSign ps = new PendingSign(pendingFile, ackFileName, content, actions);
|
||||||
pendingSigs.put(p.getUniqueId(), ps);
|
pendingSigs.put(p.getUniqueId(), ps);
|
||||||
|
|
||||||
// 创建一个 3 槽 GUI:slot0=书(完整协议)、slot1=签收、slot2=拒签
|
// 创建一个 3 槽 GUI:slot0=书(完整协议)、slot1=签收、slot2=拒签
|
||||||
org.bukkit.inventory.Inventory gui = Bukkit.createInventory(null, 3, "§6【待签收】" + new File(fileName).getName());
|
org.bukkit.inventory.Inventory gui = Bukkit.createInventory(null, 3, "§6【待签收】" + new File(pendingFile).getName());
|
||||||
|
|
||||||
// slot 0: 书与笔(完整协议内容)
|
// slot 0: 书与笔(完整协议内容)
|
||||||
ItemStack book = createBookItem(content, fileName);
|
ItemStack book = createBookItem(content, new File(pendingFile).getName());
|
||||||
gui.setItem(0, book);
|
gui.setItem(0, book);
|
||||||
|
|
||||||
// slot 1: 签收(绿)
|
// slot 1: 签收(绿)
|
||||||
@@ -471,7 +508,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
} else if (title.contains("【拒签确认】")) {
|
} else if (title.contains("【拒签确认】")) {
|
||||||
if (slot == 1 && clicked != null && clicked.getType() == Material.RED_STAINED_GLASS_PANE) {
|
if (slot == 1 && clicked != null && clicked.getType() == Material.RED_STAINED_GLASS_PANE) {
|
||||||
// 确认拒签
|
// 确认拒签
|
||||||
confirmDeny(p, new File(ps.fileName).getName(), draftSignatures.get(p.getUniqueId()));
|
confirmDeny(p, new File(ps.pendingFile).getName(), draftSignatures.get(p.getUniqueId()));
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
} else if (slot == 2 && clicked != null && clicked.getType() == Material.LIME_STAINED_GLASS_PANE) {
|
} else if (slot == 2 && clicked != null && clicked.getType() == Material.LIME_STAINED_GLASS_PANE) {
|
||||||
// 取消 → 恢复草稿
|
// 取消 → 恢复草稿
|
||||||
@@ -486,27 +523,31 @@ public class CustomScreenManager implements Listener {
|
|||||||
*/
|
*/
|
||||||
private void handleAccept(Player p, PendingSign ps, String signature) {
|
private void handleAccept(Player p, PendingSign ps, String signature) {
|
||||||
if (signature == null || signature.isEmpty()) {
|
if (signature == null || signature.isEmpty()) {
|
||||||
p.sendMessage(Component.text("§c请先点书(slot 3)输入您的签名(游戏ID)再签收"));
|
p.sendMessage(Component.text("§c请先点书(slot 0)输入您的签名(游戏ID)再签收"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!signature.equalsIgnoreCase(p.getName())) {
|
if (!signature.equalsIgnoreCase(p.getName())) {
|
||||||
p.sendMessage(Component.text("§c签名与您的游戏ID不匹配,请重新输入"));
|
p.sendMessage(Component.text("§c签名与您的游戏ID不匹配,请重新输入"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 落盘回执单
|
// 落盘回执单(全局协议:回执文件名 = 玩家名.md;玩家通知:回执文件名 = 原文件名)
|
||||||
File ackDir = new File(plugin.getDataFolder(), ps.fileName.startsWith(AGREEMENT_DIR) ? ACK_DIR_AGREEMENT : ACK_DIR_NOTIFICATION);
|
boolean isGlobal = ps.pendingFile.contains(AGREEMENT_DIR);
|
||||||
|
File ackDir = new File(plugin.getDataFolder(), isGlobal ? ACK_DIR_AGREEMENT : ACK_DIR_NOTIFICATION);
|
||||||
ensureDir(ackDir);
|
ensureDir(ackDir);
|
||||||
File ackFile = new File(ackDir, ps.fileName.substring(ps.fileName.lastIndexOf('/') + 1));
|
String ackName = isGlobal ? p.getName() + ".md" : new File(ps.pendingFile).getName();
|
||||||
|
File ackFile = new File(ackDir, ackName);
|
||||||
try {
|
try {
|
||||||
String content = "accept " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH点mm分")) + "\n";
|
String content = "accept " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH点mm分")) + "\n";
|
||||||
content += "签名:" + signature + "\n";
|
content += "签名:" + signature + "\n";
|
||||||
|
content += "来源:" + new File(ps.pendingFile).getName() + "\n";
|
||||||
Files.write(ackFile.toPath(), content.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
Files.write(ackFile.toPath(), content.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
plugin.getLogger().warning("[自定义屏幕] 写入回执单失败: " + ex.getMessage());
|
plugin.getLogger().warning("[自定义屏幕] 写入回执单失败: " + ex.getMessage());
|
||||||
p.sendMessage(Component.text("§c回执单写入失败,请联系管理员"));
|
p.sendMessage(Component.text("§c回执单写入失败,请联系管理员"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.sendMessage(Component.text("§a已签收:" + new File(ps.fileName).getName()));
|
plugin.getLogger().info("[自定义屏幕] " + p.getName() + " 签收成功: " + ackName + "(来源 " + new File(ps.pendingFile).getName() + ")");
|
||||||
|
p.sendMessage(Component.text("§a已签收:" + new File(ps.pendingFile).getName()));
|
||||||
cleanupUI(p);
|
cleanupUI(p);
|
||||||
pendingSigs.remove(p.getUniqueId());
|
pendingSigs.remove(p.getUniqueId());
|
||||||
draftSignatures.remove(p.getUniqueId());
|
draftSignatures.remove(p.getUniqueId());
|
||||||
@@ -518,9 +559,9 @@ public class CustomScreenManager implements Listener {
|
|||||||
private void handleDeny(Player p, PendingSign ps) {
|
private void handleDeny(Player p, PendingSign ps) {
|
||||||
// 二次确认:用聊天命令
|
// 二次确认:用聊天命令
|
||||||
p.sendMessage(Component.text("§c§l【拒签确认】"));
|
p.sendMessage(Component.text("§c§l【拒签确认】"));
|
||||||
p.sendMessage(Component.text("§7您即将拒签「" + new File(ps.fileName).getName() + "」"));
|
p.sendMessage(Component.text("§7您即将拒签「" + new File(ps.pendingFile).getName() + "」"));
|
||||||
p.sendMessage(Component.text("§e拒签后果:" + ps.actions.denyAction));
|
p.sendMessage(Component.text("§e拒签后果:" + ps.actions.denyAction));
|
||||||
p.sendMessage(Component.text("§7输入 /sdf1_login confirm deny " + new File(ps.fileName).getName() + " 确认拒签,或 /sdf1_login cancel 取消"));
|
p.sendMessage(Component.text("§7输入 /sdf1_login confirm deny " + new File(ps.pendingFile).getName() + " 确认拒签,或 /sdf1_login cancel 取消"));
|
||||||
pendingSigs.put(p.getUniqueId(), ps); // 保持待处理状态
|
pendingSigs.put(p.getUniqueId(), ps); // 保持待处理状态
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,8 +577,8 @@ public class CustomScreenManager implements Listener {
|
|||||||
player.sendMessage(Component.text("§c未找到待签收通知"));
|
player.sendMessage(Component.text("§c未找到待签收通知"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ps.fileName.contains(title)) {
|
if (!new File(ps.pendingFile).getName().contains(title)) {
|
||||||
player.sendMessage(Component.text("§c标题不匹配,当前待签收:" + new File(ps.fileName).getName()));
|
player.sendMessage(Component.text("§c标题不匹配,当前待签收:" + new File(ps.pendingFile).getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 执行拒签动作
|
// 执行拒签动作
|
||||||
@@ -697,8 +738,8 @@ public class CustomScreenManager implements Listener {
|
|||||||
p.sendMessage(Component.text("§c未找到待签收通知,请重新上线"));
|
p.sendMessage(Component.text("§c未找到待签收通知,请重新上线"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!ps.fileName.contains(title)) {
|
if (!new File(ps.pendingFile).getName().contains(title)) {
|
||||||
p.sendMessage(Component.text("§c标题不匹配,当前待签收:" + new File(ps.fileName).getName()));
|
p.sendMessage(Component.text("§c标题不匹配,当前待签收:" + new File(ps.pendingFile).getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
handleAccept(p, ps, signature);
|
handleAccept(p, ps, signature);
|
||||||
@@ -717,7 +758,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
p.sendMessage(Component.text("§c未找到待签收通知"));
|
p.sendMessage(Component.text("§c未找到待签收通知"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!ps.fileName.contains(title)) {
|
if (!new File(ps.pendingFile).getName().contains(title)) {
|
||||||
p.sendMessage(Component.text("§c标题不匹配"));
|
p.sendMessage(Component.text("§c标题不匹配"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -755,7 +796,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
p.sendMessage(Component.text("§c未找到待签收通知"));
|
p.sendMessage(Component.text("§c未找到待签收通知"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!ps.fileName.contains(title)) {
|
if (!new File(ps.pendingFile).getName().contains(title)) {
|
||||||
p.sendMessage(Component.text("§c标题不匹配"));
|
p.sendMessage(Component.text("§c标题不匹配"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -766,11 +807,13 @@ public class CustomScreenManager implements Listener {
|
|||||||
// ==================== 内部类 ====================
|
// ==================== 内部类 ====================
|
||||||
|
|
||||||
private static class PendingSign {
|
private static class PendingSign {
|
||||||
final String fileName;
|
final String pendingFile; // 绝对路径(用户协议/player.md 或 公告/自定义屏幕/玩家.标题.md)
|
||||||
|
final String ackFileName; // 回执文件名(全局协议=玩家名.md,玩家通知=原文件名)
|
||||||
final String content;
|
final String content;
|
||||||
final ActionConfig actions;
|
final ActionConfig actions;
|
||||||
PendingSign(String fileName, String content, ActionConfig actions) {
|
PendingSign(String pendingFile, String ackFileName, String content, ActionConfig actions) {
|
||||||
this.fileName = fileName;
|
this.pendingFile = pendingFile;
|
||||||
|
this.ackFileName = ackFileName;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user