修复容器记录+翻译集成:记录移到权限检查前,queryAndPrint异步批量翻译输出中英双语
This commit is contained in:
@@ -5404,6 +5404,15 @@ public class AreaProtection implements Listener {
|
||||
AreaConfig ac = getArea(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if (ac == null) return;
|
||||
|
||||
// ★ 领地记录(所有容器打开都记录,含领地主/管理员/公共设施)
|
||||
String containerType;
|
||||
if (loc.getBlock().getType() != org.bukkit.Material.AIR) {
|
||||
containerType = loc.getBlock().getType().name();
|
||||
} else {
|
||||
containerType = holder.getClass().getSimpleName();
|
||||
}
|
||||
plugin.landRecordManager.recordContainerOpen(ac, p, loc, containerType, e.getInventory());
|
||||
|
||||
if (hasPermission(p, ac, PermissionLevel.OWNER)) return;
|
||||
|
||||
// ★ 公共设施连控:公共设施启用时,访客自动获得容器交互权限(跳过禁止检查)
|
||||
@@ -5427,15 +5436,6 @@ public class AreaProtection implements Listener {
|
||||
|
||||
// ★ 容器交互已启用时,无权限级别的玩家也允许访问(访客权限)
|
||||
// 只有denyContainer=true时才检查权限级别
|
||||
|
||||
// ★ 领地记录:记录实际打开的容器(含打开快照用于计算拿取差异)
|
||||
String containerType;
|
||||
if (loc.getBlock().getType() != org.bukkit.Material.AIR) {
|
||||
containerType = loc.getBlock().getType().name();
|
||||
} else {
|
||||
containerType = holder.getClass().getSimpleName();
|
||||
}
|
||||
plugin.landRecordManager.recordContainerOpen(ac, p, loc, containerType, e.getInventory());
|
||||
}
|
||||
|
||||
public void loadWhitelists() {
|
||||
|
||||
@@ -263,6 +263,31 @@ public class LandRecordManager implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// 收集所有需要翻译的材料名
|
||||
Set<String> materials = new LinkedHashSet<>();
|
||||
for (Map<String, Object> r : blocks) {
|
||||
materials.add((String) r.get("material"));
|
||||
}
|
||||
for (Map<String, Object> r : containers) {
|
||||
if ("take".equals(r.get("action"))) {
|
||||
materials.add((String) r.get("detail"));
|
||||
}
|
||||
}
|
||||
|
||||
// 异步批量翻译
|
||||
MaterialTranslator.translateBatch(materials)
|
||||
.thenAccept(translations -> {
|
||||
// 回到主线程发送消息
|
||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||
printResults(p, x, y, z, blocks, containers, translations);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void printResults(Player p, int x, int y, int z,
|
||||
List<Map<String, Object>> blocks,
|
||||
List<Map<String, Object>> containers,
|
||||
Map<String, String> translations) {
|
||||
p.sendMessage("§6§l[回声碎片] §e坐标 ("
|
||||
+ x + "," + y + "," + z + ") 的记录:");
|
||||
|
||||
@@ -271,10 +296,11 @@ public class LandRecordManager implements Listener {
|
||||
for (Map<String, Object> r : blocks) {
|
||||
String act = "break".equals(r.get("action"))
|
||||
? "§c破坏" : "§a放置";
|
||||
String mat = (String) r.get("material");
|
||||
String zh = translations.getOrDefault(mat, MaterialTranslator.toReadable(mat));
|
||||
p.sendMessage(" §7" + fmt((Long) r.get("time"))
|
||||
+ " §f" + r.get("player_name")
|
||||
+ " " + act + " §e"
|
||||
+ r.get("material"));
|
||||
+ " " + act + " §e" + mat + " §a" + zh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,14 +309,17 @@ public class LandRecordManager implements Listener {
|
||||
for (Map<String, Object> r : containers) {
|
||||
String act = (String) r.get("action");
|
||||
if ("open".equals(act)) {
|
||||
String ct = (String) r.get("container_type");
|
||||
String ctZh = translations.getOrDefault(ct, MaterialTranslator.toReadable(ct));
|
||||
p.sendMessage(" §7" + fmt((Long) r.get("time"))
|
||||
+ " §f" + r.get("player_name")
|
||||
+ " §d打开§7[" + r.get("container_type")
|
||||
+ "]");
|
||||
+ " §d打开§7[" + ct + "] §a" + ctZh);
|
||||
} else if ("take".equals(act)) {
|
||||
String mat = (String) r.get("detail");
|
||||
String zh = translations.getOrDefault(mat, MaterialTranslator.toReadable(mat));
|
||||
p.sendMessage(" §7" + fmt((Long) r.get("time"))
|
||||
+ " §f" + r.get("player_name")
|
||||
+ " §c拿取 §e" + r.get("detail")
|
||||
+ " §c拿取 §e" + mat + " §a" + zh
|
||||
+ " §7x" + r.get("amount"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user