fix: 选区完成显示面积价格预览 + 用户组名大小写不敏感查找

This commit is contained in:
2026-06-28 12:52:33 +08:00
parent 5eb0000029
commit f7d13eb44c
2 changed files with 26 additions and 3 deletions
@@ -4373,6 +4373,22 @@ public class AreaProtection implements Listener {
+ block.getX() + ", "
+ block.getY() + ", "
+ block.getZ());
// ★ 两个位置都选好后,显示面积+价格预览
if (pos1.containsKey(uid)) {
Location lp1 = pos1.get(uid);
Location lp2 = block.getLocation();
int w = Math.abs(lp2.getBlockX() - lp1.getBlockX()) + 1;
int l = Math.abs(lp2.getBlockZ() - lp1.getBlockZ()) + 1;
int a = w * l;
UserGroupManager ug = plugin.getUserGroup();
int pricePerSqm = (ug != null) ? ug.getPlayerLandPricePerSqm(p.getName(), globalCreatePricePerSqm) : globalCreatePricePerSqm;
int totalCost = a * pricePerSqm;
String src = (pricePerSqm != globalCreatePricePerSqm) ? " §7(用户组优惠价)" : "";
BondManager bnd = plugin.getBonds();
int bal = (bnd != null) ? bnd.getBonds(p.getName()) : 0;
p.sendMessage("§e§l[防护] §f选区完成!面积: §a" + a + "㎡§7(" + w + "×" + l + ") 单价: §f" + pricePerSqm + "/㎡" + src + " 预估: §e" + totalCost + "§7债券 余额: §a" + bal);
p.sendMessage("§7输入 §f/protect 创建 <领地名> §7开始创建,费用和面积将再次确认");
}
}
}
return;
+10 -3
View File
@@ -144,8 +144,9 @@ public class UserGroupManager {
// ==================== 玩家操作 ====================
public boolean addPlayer(String player, String groupName, String addedBy) {
UserGroupConfig cfg = groupConfigs.get(groupName);
UserGroupConfig cfg = getGroupConfig(groupName);
if (cfg == null) return false;
groupName = cfg.name; // 使用DB中实际的组名(保留大小写)
long now = System.currentTimeMillis();
try {
PreparedStatement ps = db.prepareStatement(
@@ -283,9 +284,15 @@ public class UserGroupManager {
return groupConfigs.keySet();
}
/** 获取组配置(返回副本) */
/** 获取组配置(大小写不敏感) */
public UserGroupConfig getGroupConfig(String groupName) {
return groupConfigs.get(groupName);
UserGroupConfig cfg = groupConfigs.get(groupName);
if (cfg != null) return cfg;
// 大小写不敏感查找
for (UserGroupConfig c : groupConfigs.values()) {
if (c.name.equalsIgnoreCase(groupName)) return c;
}
return null;
}
/** 获取全部组列表(含默认组) */