修复两大关键bug:1.saveAreaToDb参数绑定从位置32开始整体偏移一位导致权限保存到错误列(权限回滚根因);2.onDisable取消所有定时任务解决async task未关闭警告

This commit is contained in:
2026-07-10 21:32:08 +08:00
parent 0354156eec
commit d306431c55
2 changed files with 62 additions and 41 deletions
+35 -37
View File
@@ -7984,43 +7984,41 @@ public class AreaProtection implements Listener {
stmt.setInt(29, ac.denyFireSpread ? 1 : 0); stmt.setInt(29, ac.denyFireSpread ? 1 : 0);
stmt.setInt(30, ac.denyAllEffects ? 1 : 0); stmt.setInt(30, ac.denyAllEffects ? 1 : 0);
stmt.setInt(31, ac.denyItemFrame ? 1 : 0); stmt.setInt(31, ac.denyItemFrame ? 1 : 0);
stmt.setInt(32, ac.denyMove ? 1 : 0); stmt.setInt(32, ac.denyEntityInteract ? 1 : 0); // ★ 修复:deny_entity_interact 列
stmt.setInt(33, ac.allowPickup ? 1 : 0); stmt.setInt(33, ac.denyMove ? 1 : 0);
stmt.setInt(34, ac.denyFire ? 1 : 0); stmt.setInt(34, ac.allowPickup ? 1 : 0);
stmt.setInt(35, ac.peaceMode ? 1 : 0); stmt.setInt(35, ac.denyFire ? 1 : 0);
stmt.setInt(36, ac.peaceModeDuration / 1000); stmt.setInt(36, ac.peaceMode ? 1 : 0);
stmt.setString(37, String.join(",", ac.peaceWhitelist)); stmt.setInt(37, ac.peaceModeDuration / 1000);
stmt.setString(38, ac.enforceGameMode != null ? ac.enforceGameMode : ""); stmt.setString(38, String.join(",", ac.peaceWhitelist));
stmt.setString(39, String.join(",", ac.modeExempt)); stmt.setString(39, ac.enforceGameMode != null ? ac.enforceGameMode : "");
stmt.setString(40, ac.enterMsg); stmt.setString(40, String.join(",", ac.modeExempt));
stmt.setString(41, ac.leaveMsg); stmt.setString(41, ac.enterMsg);
stmt.setString(42, ac.confiscateMsg); stmt.setString(42, ac.leaveMsg);
stmt.setInt(43, ac.enableAnnounce ? 1 : 0); stmt.setString(43, ac.confiscateMsg);
stmt.setString(44, ac.announceTemplate); stmt.setInt(44, ac.enableAnnounce ? 1 : 0);
stmt.setString(45, ac.txtContent != null ? ac.txtContent : ""); stmt.setString(45, ac.announceTemplate);
stmt.setLong(46, System.currentTimeMillis() / 1000); stmt.setString(46, ac.txtContent != null ? ac.txtContent : "");
// ★ 新增权限列 stmt.setLong(47, System.currentTimeMillis() / 1000);
stmt.setInt(47, ac.denyThrownProjectiles ? 1 : 0); stmt.setInt(48, ac.denyThrownProjectiles ? 1 : 0);
stmt.setInt(48, ac.denyGlowing ? 1 : 0); stmt.setInt(49, ac.denyGlowing ? 1 : 0);
stmt.setInt(49, ac.denyRedstoneInteraction ? 1 : 0); stmt.setInt(50, ac.denyRedstoneInteraction ? 1 : 0);
stmt.setInt(50, ac.denyDoorInteraction ? 1 : 0); stmt.setInt(51, ac.denyDoorInteraction ? 1 : 0);
stmt.setInt(51, ac.denyNoteblockJukebox ? 1 : 0); stmt.setInt(52, ac.denyNoteblockJukebox ? 1 : 0);
stmt.setInt(52, ac.denyLead ? 1 : 0); stmt.setInt(53, ac.denyLead ? 1 : 0);
stmt.setInt(53, ac.denyCropHarvest ? 1 : 0); stmt.setInt(54, ac.denyCropHarvest ? 1 : 0);
stmt.setInt(54, ac.denyWoolShear ? 1 : 0); stmt.setInt(55, ac.denyWoolShear ? 1 : 0);
stmt.setInt(55, ac.denyAnimalFeeding ? 1 : 0); stmt.setInt(56, ac.denyAnimalFeeding ? 1 : 0);
// ★ 传送点列 stmt.setDouble(57, ac.warpX);
stmt.setDouble(56, ac.warpX); stmt.setDouble(58, ac.warpY);
stmt.setDouble(57, ac.warpY); stmt.setDouble(59, ac.warpZ);
stmt.setDouble(58, ac.warpZ); stmt.setFloat(60, ac.warpYaw);
stmt.setFloat(59, ac.warpYaw); stmt.setFloat(61, ac.warpPitch);
stmt.setFloat(60, ac.warpPitch); stmt.setString(62, ac.warpWorld != null ? ac.warpWorld : "");
stmt.setString(61, ac.warpWorld != null ? ac.warpWorld : ""); stmt.setInt(63, ac.denyContainer ? 1 : 0);
stmt.setInt(62, ac.denyContainer ? 1 : 0); stmt.setInt(64, ac.denyMobAttack ? 1 : 0);
stmt.setInt(63, ac.denyMobAttack ? 1 : 0); stmt.setInt(65, ac.isPublicBuilding ? 1 : 0);
stmt.setInt(64, ac.isPublicBuilding ? 1 : 0); stmt.setInt(66, ac.allowVisitorTeleport ? 1 : 0);
stmt.setInt(65, ac.allowVisitorTeleport ? 1 : 0);
stmt.setInt(66, ac.denyEntityInteract ? 1 : 0);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
// ★ 领地设置变更:立即触发PHP同步(防抖10秒) // ★ 领地设置变更:立即触发PHP同步(防抖10秒)
+27 -4
View File
@@ -195,6 +195,12 @@ public class Main extends JavaPlugin
private String pendingDeleteName = null; private String pendingDeleteName = null;
private BukkitRunnable pendingDeleteTask = null; private BukkitRunnable pendingDeleteTask = null;
// ★ 定时任务引用(onDisable 时需取消)
private int chatFilterIdleTaskId = -1;
private int chatFilterCleanupTaskId = -1;
private BukkitTask glowCheckTask = null;
private BukkitTask peaceModeTask = null;
private final Map<String, PwdRollback> private final Map<String, PwdRollback>
pwdRollback = pwdRollback =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
@@ -417,11 +423,11 @@ public class Main extends JavaPlugin
// 启动广告机/挂机检测定时器 + 验证码过期清理 // 启动广告机/挂机检测定时器 + 验证码过期清理
if (chatFilter != null) { if (chatFilter != null) {
// 每60秒检查一次广告机和挂机 // 每60秒检查一次广告机和挂机
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> { chatFilterIdleTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
chatFilter.checkIdlePlayers(); chatFilter.checkIdlePlayers();
}, 6000L, 6000L); }, 6000L, 6000L);
// 每5秒清理一次过期的验证码 // 每5秒清理一次过期的验证码
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> { chatFilterCleanupTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
chatFilter.cleanupExpiredVerifications(); chatFilter.cleanupExpiredVerifications();
}, 5000L, 5000L); }, 5000L, 5000L);
} }
@@ -571,14 +577,14 @@ public class Main extends JavaPlugin
areaCLIManager = new AreaCLIManager(this, areaProtection); areaCLIManager = new AreaCLIManager(this, areaProtection);
// 发光效果检测(每2秒扫描一次) // 发光效果检测(每2秒扫描一次)
getServer().getScheduler().runTaskTimer(this, () -> { glowCheckTask = getServer().getScheduler().runTaskTimer(this, () -> {
if (areaProtection != null) { if (areaProtection != null) {
areaProtection.checkGlowingPlayers(); areaProtection.checkGlowingPlayers();
} }
}, 20L, 40L); }, 20L, 40L);
// 和平模式独立检测 // 和平模式独立检测
getServer().getScheduler().runTaskTimer(this, () -> { peaceModeTask = getServer().getScheduler().runTaskTimer(this, () -> {
if (areaProtection == null) return; if (areaProtection == null) return;
areaProtection.scanAllLandsPeaceMode(); areaProtection.scanAllLandsPeaceMode();
}, 40L, 40L); }, 40L, 40L);
@@ -747,6 +753,23 @@ public class Main extends JavaPlugin
+ pendingDeleteName); + pendingDeleteName);
pendingDeleteName = null; pendingDeleteName = null;
} }
// ★ 取消所有定时任务,避免 async task 未关闭警告
if (chatFilterIdleTaskId != -1) {
Bukkit.getScheduler().cancelTask(chatFilterIdleTaskId);
chatFilterIdleTaskId = -1;
}
if (chatFilterCleanupTaskId != -1) {
Bukkit.getScheduler().cancelTask(chatFilterCleanupTaskId);
chatFilterCleanupTaskId = -1;
}
if (glowCheckTask != null) {
glowCheckTask.cancel();
glowCheckTask = null;
}
if (peaceModeTask != null) {
peaceModeTask.cancel();
peaceModeTask = null;
}
if (db != null) db.close(); if (db != null) db.close();
if (garbage != null) garbage.close(); if (garbage != null) garbage.close();
if (questTracker != null) if (questTracker != null)