From b7b69102407b085e4eb7d590fd97180b3b82fe0f Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Tue, 24 Nov 2026 16:01:30 +0800 Subject: [PATCH] =?UTF-8?q?15m37=20=E5=B7=B2=E7=AD=BE=E6=94=B6=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E6=88=90=E4=B9=A6=E9=9D=99=E9=BB=98=E5=88=B7=E6=96=B0?= =?UTF-8?q?:=20checkAndShowPending=E6=97=A0=E5=BE=85=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=AF=B9=E5=B7=B2=E7=AD=BE=E6=94=B6=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E9=87=8D=E8=B7=91createBookItem,=20=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E8=83=8C=E5=8C=85=E6=97=A7=E6=88=90=E4=B9=A6=E4=B9=A6=E7=89=A9?= =?UTF-8?q?=E5=93=81(=E4=B8=8D=E5=BC=B9GUI=E4=B8=8DopenBook=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E6=B1=82=E9=87=8D=E7=AD=BE),=20=E8=AE=A9=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E4=B8=8D=E7=AE=A1=E4=BD=95=E6=97=B6=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=E7=9A=84=E9=83=BD=E8=83=BD=E6=8C=89=E5=BD=93=E5=89=8Djar?= =?UTF-8?q?=E6=A0=87=E5=87=86=E8=AF=BB=E5=87=BA=E6=88=90=E4=B9=A6(?= =?UTF-8?q?=E5=A6=8215m36=E9=93=BE=E6=8E=A5=E8=A1=A5=E6=9D=A5=E6=BA=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/Sdf1_login/CustomScreenManager.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/Sdf1_login/CustomScreenManager.java b/src/main/java/Sdf1_login/CustomScreenManager.java index 7944363..33983f5 100644 --- a/src/main/java/Sdf1_login/CustomScreenManager.java +++ b/src/main/java/Sdf1_login/CustomScreenManager.java @@ -169,6 +169,9 @@ public class CustomScreenManager implements Listener { String[] notiFiles = findPlayerPendingFiles(notiDir, name); if (agrFiles.length == 0 && notiFiles.length == 0) { + // 15m37 静默刷新: 已签收玩家(无待签收)也按当前 jar 重新生成成书, 替换背包里的旧成书书物品, + // 让玩家"不管何时签收的都能按新标准读出来"。不弹GUI、不openBook、不要求重签, 仅静默刷新背包成书。 + silentRefreshSignedBook(p, name, agrDir, ackDirAgr); plugin.getLogger().info("[自定义屏幕] " + name + " 无待签收(全局协议=" + agrFiles.length + " 玩家通知=" + notiFiles.length + ")"); return; // 无待签收 } @@ -245,6 +248,48 @@ public class CustomScreenManager implements Listener { return pending.toArray(new String[0]); } + /** + * 15m37 静默刷新已签收玩家的成书: 扫 用户协议 目录, 对玩家已签收的 .md(回执存在) + * 按当前 jar 重新 createBookItem 生成新成书, 替换玩家背包里的旧成书书物品。 + * 不弹GUI、不openBook、不要求重签 —— 让玩家"不管何时签收的都能按新标准读出来"。 + * 仅当背包里已有同类成书书物品时替换(避免往满背包塞新书打扰玩家)。 + */ + private void silentRefreshSignedBook(Player p, String name, File agrDir, File ackDir) { + if (agrDir == null || !agrDir.exists() || !agrDir.isDirectory()) return; + File[] files = agrDir.listFiles((d, n) -> n.endsWith(".md")); + if (files == null || files.length == 0) return; + // 回执: 玩家名.md 存在=已签收 + File ackFile = new File(ackDir, name + ".md"); + if (!ackFile.exists() || ackFile.length() == 0) return; // 未签收, 走正常弹窗路径, 不在此刷新 + + // 已签收: 重新生成新成书 + for (File f : files) { + String content; + try { + content = new String(Files.readAllBytes(f.toPath())); + } catch (Exception ex) { + continue; + } + String displayContent = stripJsonBlock(content); + try { + ItemStack newBook = createBookItem(displayContent, f.getName()); + if (newBook == null || newBook.getType() != Material.WRITTEN_BOOK) continue; + // 背包里找旧成书书物品(WRITTEN_BOOK)替换为新书; 找不到旧书则不动(避免塞满背包) + org.bukkit.inventory.Inventory inv = p.getInventory(); + int oldIdx = -1; + for (int i = 0; i < inv.getStorageContents().length; i++) { + ItemStack it = inv.getItem(i); + if (it != null && it.getType() == Material.WRITTEN_BOOK) { oldIdx = i; break; } + } + if (oldIdx >= 0) { + inv.setItem(oldIdx, newBook); + p.updateInventory(); + } + } catch (Exception ignored) {} + break; // 一个全局协议足够 + } + } + /** * 玩家通知:按 {玩家名}.*.md 匹配,签收回执 = 原文件名。 */