fix(core): restore PHP sync disabled for debugging; root cause confirmed as INSERT OR REPLACE id change

This commit is contained in:
2026-07-10 15:29:03 +08:00
parent ebd26ee123
commit 0775f2e84d
2 changed files with 42 additions and 50 deletions
+21 -22
View File
@@ -6000,12 +6000,12 @@ public class AreaProtection implements Listener {
sender.sendMessage("§c未知配置项: " + key); sender.sendMessage("§c未知配置项: " + key);
return true; return true;
} }
// ★ [已注释] 配置变更:PHP同步暂时禁用(排查领地权限被强制同步bug) // ★ 配置变更:立即触发PHP同步
// try { try {
// if (plugin.webManager != null) { if (plugin.webManager != null) {
// plugin.webManager.requestImmediateLandSync(); plugin.webManager.requestImmediateLandSync();
// } }
// } catch (Exception ignored) {} } catch (Exception ignored) {}
// ★ 更新后显示完整配置页面(而非仅打印"已更新") // ★ 更新后显示完整配置页面(而非仅打印"已更新")
if (plugin.areaCLIManager != null) { if (plugin.areaCLIManager != null) {
@@ -7597,8 +7597,8 @@ public class AreaProtection implements Listener {
areaName, oldOwner, newOwner, expiresAt, 0, 0, snapshot areaName, oldOwner, newOwner, expiresAt, 0, 0, snapshot
); );
plugin.webManager.trackTransfer(areaName, info); plugin.webManager.trackTransfer(areaName, info);
// 通知PHP同步 [已注释 - 排查权限强制同步bug] // 通知PHP同步
// plugin.webManager.requestImmediateLandSync(); plugin.webManager.requestImmediateLandSync();
} }
sender.sendMessage("§a已将 §e" + areaName + " §a从 §e" + (oldOwner != null ? oldOwner : "无") + " §a转让给 §e" + newOwner + "§a,§e60秒冷却期内可取消"); sender.sendMessage("§a已将 §e" + areaName + " §a从 §e" + (oldOwner != null ? oldOwner : "无") + " §a转让给 §e" + newOwner + "§a,§e60秒冷却期内可取消");
@@ -7969,12 +7969,12 @@ public class AreaProtection implements Listener {
stmt.setInt(65, ac.allowVisitorTeleport ? 1 : 0); stmt.setInt(65, ac.allowVisitorTeleport ? 1 : 0);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
// ★ [已注释] 领地设置变更:PHP同步暂时禁用(排查权限强制同步bug) // ★ 领地设置变更:立即触发PHP同步(防抖10秒)
// try { try {
// if (plugin.webManager != null) { if (plugin.webManager != null) {
// plugin.webManager.requestImmediateLandSync(); plugin.webManager.requestImmediateLandSync();
// } }
// } catch (Exception ignored) {} } catch (Exception ignored) {}
} catch (SQLException e) { } catch (SQLException e) {
plugin.getLogger().warning("[防护] 保存到DB失败: " + ac.name + " - " + e.getMessage()); plugin.getLogger().warning("[防护] 保存到DB失败: " + ac.name + " - " + e.getMessage());
} }
@@ -7990,12 +7990,12 @@ public class AreaProtection implements Listener {
stmt.setString(1, name); stmt.setString(1, name);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
// ★ [已注释] 领地删除:PHP同步暂时禁用(排查权限强制同步bug) // ★ 领地删除:立即触发PHP同步
// try { try {
// if (plugin.webManager != null) { if (plugin.webManager != null) {
// plugin.webManager.requestImmediateLandSync(); plugin.webManager.requestImmediateLandSync();
// } }
// } catch (Exception ignored) {} } catch (Exception ignored) {}
} catch (SQLException e) { } catch (SQLException e) {
plugin.getLogger().warning("[防护] 从DB删除领地失败: " + name + " - " + e.getMessage()); plugin.getLogger().warning("[防护] 从DB删除领地失败: " + name + " - " + e.getMessage());
} }
@@ -8775,8 +8775,7 @@ public class AreaProtection implements Listener {
areaName, oldOwner, newOwner, expiresAt, 0, 0, snapshot areaName, oldOwner, newOwner, expiresAt, 0, 0, snapshot
); );
plugin.webManager.trackTransfer(areaName, info); plugin.webManager.trackTransfer(areaName, info);
// [已注释] PHP同步暂时禁用(排查权限强制同步bug) plugin.webManager.requestImmediateLandSync();
// plugin.webManager.requestImmediateLandSync();
} }
p.sendMessage("§a已将 §e" + areaName + " §a从 §e" + (oldOwner != null ? oldOwner : "无") + " §a转让给 §e" + newOwner + "§a,§e60秒冷却期内可取消"); p.sendMessage("§a已将 §e" + areaName + " §a从 §e" + (oldOwner != null ? oldOwner : "无") + " §a转让给 §e" + newOwner + "§a,§e60秒冷却期内可取消");
+21 -28
View File
@@ -3819,38 +3819,31 @@ public class WebManager {
break; break;
} }
case "perm_change": { case "perm_change": {
// [已注释] PHP→Java权限同步暂时禁用(排查领地权限被强制同步bug) // handleUpdateVisitorPerm: target_name=玩家名,changeData 不含 player
plugin.getLogger().info("[Web通信] [已跳过] PHP端perm_change: " + targetName + " (禁用中)"); // handleChangeVisitorRole: target_name=领地名,changeData 含 player
applied = true; String playerName = changeData.containsKey("player")
? String.valueOf(changeData.get("player"))
: targetName;
String landNameJson = String.valueOf(changeData.getOrDefault("land_name", ""));
String permsJson = String.valueOf(changeData.getOrDefault("permissions", "{}"));
String roleJson = String.valueOf(changeData.getOrDefault("role", ""));
if (!playerName.isEmpty() && !landNameJson.isEmpty()) {
areaProtect.updateVisitorPermFromWeb(landNameJson, playerName, permsJson, roleJson);
plugin.getLogger().info("[Web通信] PHP端更新访客权限: " + playerName + " @ " + landNameJson
+ (roleJson.isEmpty() ? "" : " role=" + roleJson));
applied = true;
}
break; break;
// ★ 以下是原逻辑(暂时禁用)
// String playerName = changeData.containsKey("player")
// ? String.valueOf(changeData.get("player"))
// : targetName;
// String landNameJson = String.valueOf(changeData.getOrDefault("land_name", ""));
// String permsJson = String.valueOf(changeData.getOrDefault("permissions", "{}"));
// String roleJson = String.valueOf(changeData.getOrDefault("role", ""));
// if (!playerName.isEmpty() && !landNameJson.isEmpty()) {
// areaProtect.updateVisitorPermFromWeb(landNameJson, playerName, permsJson, roleJson);
// plugin.getLogger().info("[Web通信] PHP端更新访客权限: " + playerName + " @ " + landNameJson
// + (roleJson.isEmpty() ? "" : " role=" + roleJson));
// applied = true;
// }
// break;
} }
case "land_field_change": { case "land_field_change": {
// [已注释] PHP→Java领地字段同步暂时禁用(排查权限强制同步bug) String field = String.valueOf(changeData.getOrDefault("field", ""));
plugin.getLogger().info("[Web通信] [已跳过] PHP端land_field_change: " + targetName + " (禁用中)"); String value = String.valueOf(changeData.getOrDefault("value", ""));
applied = true; if (!field.isEmpty() && !targetName.isEmpty()) {
areaProtect.updateLandFieldFromWeb(targetName, field, value);
plugin.getLogger().info("[Web通信] PHP端更新领地字段: " + targetName + "." + field);
applied = true;
}
break; break;
// String field = String.valueOf(changeData.getOrDefault("field", ""));
// String value = String.valueOf(changeData.getOrDefault("value", ""));
// if (!field.isEmpty() && !targetName.isEmpty()) {
// areaProtect.updateLandFieldFromWeb(targetName, field, value);
// plugin.getLogger().info("[Web通信] PHP端更新领地字段: " + targetName + "." + field);
// applied = true;
// }
// break;
} }
case "config_change": { case "config_change": {
String configKey = String.valueOf(changeData.getOrDefault("key", "")); String configKey = String.valueOf(changeData.getOrDefault("key", ""));