From ae788f94d14e1478c193408fdc520aef4c53e93b Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Thu, 29 Oct 2026 22:07:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC61=E6=89=B9-=E7=BB=AD3=EF=BC=9A?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=87=E4=BB=B6=E9=80=9A=E7=9F=A5=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=EF=BC=88=E8=B7=A8=E6=9C=BA=E9=83=A8=E7=BD=B2=E6=97=A0?= =?UTF-8?q?=E6=95=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - checkSyncNotify() 改为空实现,依赖定时器B每5秒轮询 - PHP端 notifySync() 不再写 sync_notify.txt - 理由:不是所有MC服务器和web部署在同一台机器,文件不共享 --- src/main/java/Sdf1_login/WebManager.java | 50 +++--------------------- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/src/main/java/Sdf1_login/WebManager.java b/src/main/java/Sdf1_login/WebManager.java index 143a93e..5477291 100644 --- a/src/main/java/Sdf1_login/WebManager.java +++ b/src/main/java/Sdf1_login/WebManager.java @@ -12197,53 +12197,15 @@ public class WebManager { /** * 检查同步通知文件 + * ★ 第61批-续2:移除文件通知机制 + * 原逻辑:读取 sync_notify.txt 文件触发同步 + * 问题:不是所有 MC 服务器和 web 部署在同一台机器,文件不共享 + * 修复:依赖定时器B每5秒轮询 check_pending_transactions */ private void checkSyncNotify() { - try { - File notifyFile = new File(plugin.getDataFolder(), "../sync_notify.txt"); - if (notifyFile.exists()) { - String content = new String(java.nio.file.Files.readAllBytes(notifyFile.toPath())).trim(); - // ★ 兼容两种格式:纯数字时间戳 或 JSON {"time":xxx,"tx_id":xxx} - long notifyTime = 0; - if (content.startsWith("{")) { - // JSON格式 - int timeIdx = content.indexOf("\"time\":"); - if (timeIdx > 0) { - int start = timeIdx + 8; - int end = content.indexOf(",", start); - if (end < 0) end = content.indexOf("}", start); - if (end > start) { - notifyTime = Long.parseLong(content.substring(start, end).trim()); - } - } - } else { - notifyTime = Long.parseLong(content); - } - long now = System.currentTimeMillis(); - // 如果通知时间在5分钟内,执行同步 - if (notifyTime > 0 && now - notifyTime < 300000) { - // 有人在线才响应通知 - if (!Bukkit.getOnlinePlayers().isEmpty()) { - // ★ 通过DB队列串行化执行同步 - submitDbTask("通知-syncOnlinePlayers", () -> syncOnlinePlayers(), true); - submitDbTask("通知-pushWebLoginCredentials", () -> pushWebLoginCredentials()); - submitDbTask("通知-syncUserRegistrations", () -> syncUserRegistrations()); - submitDbTask("通知-syncServiceProviders", () -> syncServiceProviders()); - submitDbTask("通知-syncShopData", () -> syncShopData()); - submitNormalDbTask("通知-pullPendingTransactions", () -> pullPendingTransactions()); - submitNormalDbTask("通知-pullShopStock", () -> pullShopStock()); - submitNormalDbTask("通知-pullShopPrices", () -> pullShopPrices()); - submitNormalDbTask("通知-pullShopConfig", () -> pullShopConfig()); - submitNormalDbTask("通知-pullBondChanges", () -> pullBondChanges()); - // 删除通知文件 - notifyFile.delete(); - } - } - } - } catch (Exception e) { - // 静默处理 - } + // 已废弃:文件通知机制在跨机部署时无效 + // 同步由定时器B的 doTransactionPollCheck() 每5秒轮询驱动 } /**