diff --git a/src/main/java/Sdf1_login/AreaProtection.java b/src/main/java/Sdf1_login/AreaProtection.java index ff26df1..c59386c 100644 --- a/src/main/java/Sdf1_login/AreaProtection.java +++ b/src/main/java/Sdf1_login/AreaProtection.java @@ -110,6 +110,7 @@ public class AreaProtection implements Listener { // ★ 全局配置默认值 private int globalCreatePricePerSqm = 10; // 每㎡创建价格 private int globalMaxLandsPerPlayer = 5; // 每人最多领地数 + private int globalMaxHomePerPlayer = 5; // 每人最多传送点(home)数量 private int globalDefaultHeight = 255; // 默认高度 // 选地 @@ -1211,6 +1212,7 @@ public class AreaProtection implements Listener { if (configCount == 0) { stmt.executeUpdate("INSERT OR IGNORE INTO area_config VALUES ('create_price_per_sqm', '10')"); stmt.executeUpdate("INSERT OR IGNORE INTO area_config VALUES ('max_lands_per_player', '5')"); + stmt.executeUpdate("INSERT OR IGNORE INTO area_config VALUES ('max_home_per_player', '5')"); stmt.executeUpdate("INSERT OR IGNORE INTO area_config VALUES ('default_height', '255')"); stmt.executeUpdate("INSERT OR IGNORE INTO area_config VALUES ('peace_mode_max_duration', '3600')"); } @@ -1223,6 +1225,7 @@ public class AreaProtection implements Listener { switch (k) { case "create_price_per_sqm": globalCreatePricePerSqm = Integer.parseInt(v); break; case "max_lands_per_player": globalMaxLandsPerPlayer = Integer.parseInt(v); break; + case "max_home_per_player": globalMaxHomePerPlayer = Integer.parseInt(v); break; case "default_height": globalDefaultHeight = Integer.parseInt(v); break; } } catch (NumberFormatException ignored) {} @@ -8200,11 +8203,27 @@ public class AreaProtection implements Listener { ps.setString(3, value); ps.executeUpdate(); ps.close(); + // ★ 同步更新内存字段,使Web配置变更立即生效(无需等待下次轮询reload) + try { + switch (key) { + case "create_price_per_sqm": globalCreatePricePerSqm = Integer.parseInt(value); break; + case "max_lands_per_player": globalMaxLandsPerPlayer = Integer.parseInt(value); break; + case "max_home_per_player": globalMaxHomePerPlayer = Integer.parseInt(value); break; + case "default_height": globalDefaultHeight = Integer.parseInt(value); break; + } + } catch (NumberFormatException ignored) {} } catch (Exception e) { plugin.getLogger().warning("[防护] 更新配置失败: " + e.getMessage()); } } + /** + * ★ 获取全局家(home)数量上限 + */ + public int getGlobalMaxHomePerPlayer() { + return globalMaxHomePerPlayer; + } + /** * ★ 获取area_config表中的配置值 */ diff --git a/src/main/java/Sdf1_login/HomeManager.java b/src/main/java/Sdf1_login/HomeManager.java index fe0a3a2..3d28a4a 100644 --- a/src/main/java/Sdf1_login/HomeManager.java +++ b/src/main/java/Sdf1_login/HomeManager.java @@ -285,9 +285,19 @@ public class HomeManager implements Listener { /** * 获取全局家数量限制 + * 读取area_config中的max_home_per_player配置(管理员可在Web后台调整) + * 解析失败或值<=0时回退到默认5 */ private int getGlobalHomeLimit() { - // 默认5个家,可从配置文件读取 + try { + if (plugin.areaProtection != null) { + int limit = plugin.areaProtection.getGlobalMaxHomePerPlayer(); + if (limit > 0) { + return limit; + } + } + } catch (Exception ignored) {} + // 默认5个家 return 5; }