新增maxhome全局传送点上限参数,并联动用户组home_limit(#726)
- AreaProtection新增max_home_per_player全局配置,复用现有area_config/web_area_config通路 - updateAreaConfig同步刷新内存字段,Web后台修改后立即生效 - HomeManager.getGlobalHomeLimit改为读取area_config,解析失败或<=0回退默认5 - 用户组home_limit(>0覆盖/0跟随/-1无限)逻辑不变,形成完整联动
This commit is contained in:
@@ -110,6 +110,7 @@ public class AreaProtection implements Listener {
|
|||||||
// ★ 全局配置默认值
|
// ★ 全局配置默认值
|
||||||
private int globalCreatePricePerSqm = 10; // 每㎡创建价格
|
private int globalCreatePricePerSqm = 10; // 每㎡创建价格
|
||||||
private int globalMaxLandsPerPlayer = 5; // 每人最多领地数
|
private int globalMaxLandsPerPlayer = 5; // 每人最多领地数
|
||||||
|
private int globalMaxHomePerPlayer = 5; // 每人最多传送点(home)数量
|
||||||
private int globalDefaultHeight = 255; // 默认高度
|
private int globalDefaultHeight = 255; // 默认高度
|
||||||
|
|
||||||
// 选地
|
// 选地
|
||||||
@@ -1211,6 +1212,7 @@ public class AreaProtection implements Listener {
|
|||||||
if (configCount == 0) {
|
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 ('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_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 ('default_height', '255')");
|
||||||
stmt.executeUpdate("INSERT OR IGNORE INTO area_config VALUES ('peace_mode_max_duration', '3600')");
|
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) {
|
switch (k) {
|
||||||
case "create_price_per_sqm": globalCreatePricePerSqm = Integer.parseInt(v); break;
|
case "create_price_per_sqm": globalCreatePricePerSqm = Integer.parseInt(v); break;
|
||||||
case "max_lands_per_player": globalMaxLandsPerPlayer = 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;
|
case "default_height": globalDefaultHeight = Integer.parseInt(v); break;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {}
|
||||||
@@ -8200,11 +8203,27 @@ public class AreaProtection implements Listener {
|
|||||||
ps.setString(3, value);
|
ps.setString(3, value);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
ps.close();
|
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) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().warning("[防护] 更新配置失败: " + e.getMessage());
|
plugin.getLogger().warning("[防护] 更新配置失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 获取全局家(home)数量上限
|
||||||
|
*/
|
||||||
|
public int getGlobalMaxHomePerPlayer() {
|
||||||
|
return globalMaxHomePerPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ★ 获取area_config表中的配置值
|
* ★ 获取area_config表中的配置值
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -285,9 +285,19 @@ public class HomeManager implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全局家数量限制
|
* 获取全局家数量限制
|
||||||
|
* 读取area_config中的max_home_per_player配置(管理员可在Web后台调整)
|
||||||
|
* 解析失败或值<=0时回退到默认5
|
||||||
*/
|
*/
|
||||||
private int getGlobalHomeLimit() {
|
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;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user