From 10e148be5f58330ddb0e69ad9df47543d380e9a6 Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Thu, 25 Jun 2026 13:05:41 +0800 Subject: [PATCH] =?UTF-8?q?v9:=20=E4=BF=AE=E5=A4=8DpollAdminChanges=20404?= =?UTF-8?q?=20+=20=E5=BB=B6=E8=BF=9F=E5=A2=9E=E5=88=B08-10=E7=A7=92=20-=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20ack=5Fadmin=5Fchanges=20double=20URL=20bug?= =?UTF-8?q?=EF=BC=88httpPost=E9=87=8D=E5=A4=8D=E6=8B=BC=E6=8E=A5webBaseUrl?= =?UTF-8?q?=EF=BC=89=20-=20=E6=94=B9=E7=94=A8GET=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=8F=91=E9=80=81ack=EF=BC=8C=E9=81=BF=E5=85=8DPOST=20Content-?= =?UTF-8?q?Type=E4=B8=8D=E5=8C=B9=E9=85=8D=20-=20land=5Fapi.php=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81GET=E5=8F=82=E6=95=B0ids=20-=20=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=BB=BB=E5=8A=A1=E9=97=B4=E9=9A=8F=E6=9C=BA=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E4=BB=8E6-8=E7=A7=92=E5=A2=9E=E5=88=B08-10=E7=A7=92?= =?UTF-8?q?=20-=20=E7=9B=AE=E6=A0=87=EF=BC=9A=E9=94=81=E5=BA=93=E9=99=8D?= =?UTF-8?q?=E5=88=B00-1=E6=AC=A1/=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Sdf1_login/WebManager.java | 70 ++++++++++++------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/main/java/Sdf1_login/WebManager.java b/src/main/java/Sdf1_login/WebManager.java index 01e8661..70f4e3b 100644 --- a/src/main/java/Sdf1_login/WebManager.java +++ b/src/main/java/Sdf1_login/WebManager.java @@ -801,24 +801,24 @@ public class WebManager { plugin.getLogger().info("[Web通信] 开始首次全量同步(通过DB队列串行化)..."); // 登录相关操作高优先级 submitDbTask("首次-syncUserRegistrations", () -> syncUserRegistrations()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("首次-pushWebLoginCredentials", () -> pushWebLoginCredentials()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} // 普通同步操作低优先级(每个任务间随机间隔2-4秒,避免PHP端DB锁) submitNormalDbTask("首次-syncOnlinePlayers", () -> syncOnlinePlayers()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-syncShopData", () -> syncShopData()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-syncBondBalances", () -> syncBondBalances()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-syncBondTransactions", () -> syncBondTransactions()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-syncAllPlayerIps", () -> syncAllPlayerIps()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-syncServiceProviders", () -> syncServiceProviders()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-syncLandData", () -> syncLandData()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("首次-pollAdminChanges", () -> pollAdminChanges()); } }.runTaskLaterAsynchronously(plugin, 20L * 10); @@ -1189,19 +1189,19 @@ public class WebManager { plugin.getLogger().info("[Web通信] 收到即时同步请求: " + players.toString()); // 通过DB队列串行化执行(每个任务间错开800ms) submitDbTask("即时-syncOnlinePlayers", () -> syncOnlinePlayers()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("即时-pushWebLoginCredentials", () -> pushWebLoginCredentials()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("即时-syncUserRegistrations", () -> syncUserRegistrations()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("即时-pullPendingTransactions", () -> pullPendingTransactions()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("即时-pullShopStock", () -> pullShopStock()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("即时-pullBondChanges", () -> pullBondChanges()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("即时-syncAllPlayerIps", () -> syncAllPlayerIps()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("即时-syncServiceProviders", () -> syncServiceProviders()); } } @@ -1224,17 +1224,17 @@ public class WebManager { lastOnlineCheckTime = System.currentTimeMillis(); // 通过DB队列串行化执行最后一轮同步(每个任务间随机间隔2-4秒,避免与定时轮询冲突) submitDbTask("末轮-syncOnlinePlayers", () -> syncOnlinePlayers()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("末轮-pushWebLoginCredentials", () -> pushWebLoginCredentials()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("末轮-syncUserRegistrations", () -> syncUserRegistrations()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("末轮-syncBondTransactions", () -> syncBondTransactions()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("末轮-pullPendingTransactions", () -> pullPendingTransactions()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("末轮-pullShopStock", () -> pullShopStock()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("末轮-pullBondChanges", () -> pullBondChanges()); plugin.getLogger().info("[Web通信] 检测到全员下线超60秒,执行最后一轮同步(通过DB队列),调度器继续运行(玩家上线自动恢复)"); plugin.getLogger().warning("\n" + @@ -1285,28 +1285,28 @@ public class WebManager { // 登录/注册相关(始终执行,随机间隔2-4秒避免PHP端DB锁) submitDbTask("周期-pushWebLoginCredentials", () -> pushWebLoginCredentials()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("周期-syncUserRegistrations", () -> syncUserRegistrations()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} if (online) { // 在线:执行全量同步(每个任务随机间隔2-4秒) submitDbTask("周期-syncOnlinePlayers", () -> syncOnlinePlayers()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitDbTask("周期-syncBondTransactions", () -> syncBondTransactions()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-pullPendingTransactions", () -> pullPendingTransactions()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-pullShopStock", () -> pullShopStock()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-pullBondChanges", () -> pullBondChanges()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-syncAllPlayerIps", () -> syncAllPlayerIps()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-syncServiceProviders", () -> syncServiceProviders()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-syncLandData", () -> syncLandData()); - try { Thread.sleep(6000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} + try { Thread.sleep(8000 + (long)(Math.random() * 2000)); } catch (InterruptedException ignored) {} submitNormalDbTask("周期-pollAdminChanges", () -> pollAdminChanges()); } else { // ★ 不在线:跳过非必要同步任务 @@ -2621,9 +2621,9 @@ public class WebManager { // 确认已处理的变更 if (!ackedIds.isEmpty()) { - String ackUrl = webBaseUrl + "/api/land_api.php?action=ack_admin_changes&secret=" + secretKey; - String ackBody = "ids=" + String.join(",", ackedIds.stream().map(String::valueOf).collect(Collectors.toList())); - httpPost(ackUrl, ackBody); + String idsStr = String.join(",", ackedIds.stream().map(String::valueOf).collect(Collectors.toList())); + String ackUrl = "/api/land_api.php?action=ack_admin_changes&secret=" + java.net.URLEncoder.encode(secretKey, "UTF-8") + "&ids=" + java.net.URLEncoder.encode(idsStr, "UTF-8"); + doGet(ackUrl); } } catch (Exception e) { plugin.getLogger().warning("[Web通信] 轮询PHP管理员变更异常: " + e.getMessage());