PVP和平扫描改每tick实时 + 日志静默(成功不吭声失败才报)
Auto Release / build (push) Successful in 2m23s

- 周期 40 tick(2秒) → 1 tick:苦力怕引信 30 tick(1.5秒),
  2 秒足够它引爆,残血玩家危险
- 删掉 removed>0 的 info 日志,整段包 try-catch,
  只有抛异常才 severe 打哪里出了问题
This commit is contained in:
youpaishidifu
2026-11-09 18:14:00 +08:00
parent 9fcd845410
commit 3aaf00ce2c
@@ -578,7 +578,9 @@ public class PVPArenaManager implements Listener {
}
// ★ 插件语义"和平模式":PVP 世界保持 NORMAL 难度(原生和平会强制回血+不消耗饱食度,
// 杀敌极困难),由本任务每 2 秒剔除玩家周边 32 格内的敌对生物,达到和平效果。
// 杀敌极困难),由本任务每 tick 实时剔除玩家周边 32 格内的敌对生物,达到和平效果。
// 周期必须 1 tick:苦力怕引信 30 tick(1.5 秒),2 秒周期足够它引爆,残血玩家危险。
// 日志静默:成功不吭声;只有抛异常才 severe 报哪里出了问题。
// 复用 AreaProtection 的 HOSTILE_TYPES 判定口径(isHostile 私有,此处独立维护同一份词表)。
private static final Set<String> PVP_HOSTILE_TYPES = new HashSet<>(Arrays.asList(
"ZOMBIE", "ZOMBIE_VILLAGER", "HUSK", "DROWNED",
@@ -597,22 +599,22 @@ public class PVPArenaManager implements Listener {
private void startPeacefulMobCleanupTask() {
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
try {
World w = Bukkit.getWorld(pvpWorldName);
if (w == null || w.getPlayers().isEmpty()) return;
final double RADIUS = 32.0;
int removed = 0;
for (Player p : w.getPlayers()) {
for (Entity ent : w.getNearbyEntities(p.getLocation(), RADIUS, RADIUS, RADIUS)) {
if (PVP_HOSTILE_TYPES.contains(ent.getType().name())) {
ent.remove();
removed++;
}
}
}
if (removed > 0) {
plugin.getLogger().info("[PVP和平] 本轮剔除玩家周边敌对生物 " + removed + " 个");
} catch (Throwable t) {
// ★ 静默原则:成功不吭声,失败才张嘴说哪里出了问题
plugin.getLogger().severe("[PVP和平] 扫描剔除失败: " + t);
}
}, 40L, 40L);
}, 1L, 1L);
}
/**