【长句翻译静默根因实锤】日志 `[机翻调度] 闸3含URL→跳过 URL=[myself.it]`: "myself. It" 被 URL_PATTERN 点分隔支匹配成 myself.it(it=意大利 ccTLD 在 illegal_domains.txt 里)→ 闸3 整句 return 不翻译。修:闸3 改只拦「真正会被 onChat 拦截的 URL」(显式协议:// 或 shouldBlockUrl 判非法);裸 ccTLD 误判 token(myself.it/sdf1.it 等)放行翻译。 【PVP 中立生物转敌对未清理】用户顺手发现:狼/铁傀儡/蜜蜂等中立生物被玩家 误打转敌对后插件未接管清理(只清纯敌对)。新增 PVP_NEUTRAL_TYPES + shouldRemoveForPeaceful:纯敌对一律清;中立生物仅在带仇恨目标 (Mob#getTargetEntity(32) 非空) 时清,驯服狼 target 为空不动。
This commit is contained in:
@@ -7119,9 +7119,22 @@ public class Main extends JavaPlugin
|
|||||||
+ " IP=" + chatFilter.extractIpAddresses(text));
|
+ " IP=" + chatFilter.extractIpAddresses(text));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!chatFilter.extractUrls(text).isEmpty()) {
|
// ★ 第123批再续11:URL 闸只拦「真正会被 onChat 拦截的 URL」(显式协议:// 或
|
||||||
getLogger().info("[机翻调度] 闸3含URL→跳过 玩家=" + p.getName()
|
// 命中非法域名后缀),裸域名 token 误判(如 "myself. It" 被点分隔支匹配成
|
||||||
+ " URL=" + chatFilter.extractUrls(text));
|
// "myself.it",it=意大利 ccTLD 在 illegal_domains.txt 里)不再静默吞掉整句翻译。
|
||||||
|
// 判据:extractUrls 结果里存在 shouldBlockUrl==true 的才拦;
|
||||||
|
// 白名单/合法/纯误判的裸 token 放行机翻。
|
||||||
|
List<String> urlsFound = chatFilter.extractUrls(text);
|
||||||
|
boolean hasBlockingUrl = false;
|
||||||
|
for (String u : urlsFound) {
|
||||||
|
if (u.contains("://") || chatFilter.shouldBlockUrl(u)) {
|
||||||
|
hasBlockingUrl = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasBlockingUrl) {
|
||||||
|
getLogger().info("[机翻调度] 闸3含真URL→跳过 玩家=" + p.getName()
|
||||||
|
+ " URL=" + urlsFound);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -715,6 +715,36 @@ public class PVPArenaManager implements Listener {
|
|||||||
"ENDERMAN", "WITHER"
|
"ENDERMAN", "WITHER"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第123批再续11:PVP 场地中立生物清单(狼/铁傀儡/蜜蜂/狐狸/熊猫/兔子/猫/猪等)。
|
||||||
|
* 这些生物平时中立不清理;一旦被玩家攻击转为敌对(带仇恨目标)就即时剔除,
|
||||||
|
* 避免玩家误打中立生物后它反追玩家(PVP 场地里中立生物本就不该有威胁)。
|
||||||
|
*/
|
||||||
|
private static final Set<String> PVP_NEUTRAL_TYPES = new HashSet<>(Arrays.asList(
|
||||||
|
"WOLF", "IRON_GOLEM", "BEE", "FOX", "PANDA", "RABBIT", "CAT", "OCELOT"
|
||||||
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判定一个实体是否该被 PVP 和平清理:
|
||||||
|
* ① 纯敌对生物(类型在 PVP_HOSTILE_TYPES)→ 一律清;
|
||||||
|
* ② 中立生物(类型在 PVP_NEUTRAL_TYPES)且当前处于敌对状态 → 清。
|
||||||
|
* 敌对状态判据:Mob 带仇恨目标(getTargetEntity 非空)或被玩家/实体仇恨
|
||||||
|
* (Paper 26.3:Mob#getTargetEntity 返回 HumanEntity;驯服过的狼 target 为空不动)。
|
||||||
|
*/
|
||||||
|
private boolean shouldRemoveForPeaceful(World w, Entity ent) {
|
||||||
|
if (ent == null || ent instanceof Player) return false;
|
||||||
|
if (PVP_HOSTILE_TYPES.contains(ent.getType().name())) return true;
|
||||||
|
// 中立生物:仅在转敌对时清
|
||||||
|
if (PVP_NEUTRAL_TYPES.contains(ent.getType().name())) {
|
||||||
|
if (ent instanceof org.bukkit.entity.Mob) {
|
||||||
|
org.bukkit.entity.Mob mob = (org.bukkit.entity.Mob) ent;
|
||||||
|
// 带仇恨目标(被玩家攻击后锁定目标,32 格内)→ 敌对,剔除
|
||||||
|
if (mob.getTargetEntity(32) != null) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void startPeacefulMobCleanupTask() {
|
private void startPeacefulMobCleanupTask() {
|
||||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||||
try {
|
try {
|
||||||
@@ -723,7 +753,7 @@ public class PVPArenaManager implements Listener {
|
|||||||
final double RADIUS = 32.0;
|
final double RADIUS = 32.0;
|
||||||
for (Player p : w.getPlayers()) {
|
for (Player p : w.getPlayers()) {
|
||||||
for (Entity ent : w.getNearbyEntities(p.getLocation(), RADIUS, RADIUS, RADIUS)) {
|
for (Entity ent : w.getNearbyEntities(p.getLocation(), RADIUS, RADIUS, RADIUS)) {
|
||||||
if (PVP_HOSTILE_TYPES.contains(ent.getType().name())) {
|
if (shouldRemoveForPeaceful(w, ent)) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user