From 6f004f257fdaf269e024c6a329fb9a4d74687145 Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Thu, 2 Jul 2026 21:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=86=E5=9C=B0=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E7=82=B9=E7=87=83=EF=BC=9A=E6=94=AF=E6=8C=81BlockIgni?= =?UTF-8?q?teEvent+EntityExplodeEvent+BlockExplodeEvent=E5=A4=9A=E5=B1=82?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=EF=BC=8C=E8=A6=86=E7=9B=96TNT/=E7=81=AB?= =?UTF-8?q?=E5=BA=8A/=E7=83=88=E7=84=B0=E5=BC=B9=E7=AD=89=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Sdf1_login/AreaProtection.java | 61 ++++++++++++++++++-- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/src/main/java/Sdf1_login/AreaProtection.java b/src/main/java/Sdf1_login/AreaProtection.java index 2ddad79..85fac94 100644 --- a/src/main/java/Sdf1_login/AreaProtection.java +++ b/src/main/java/Sdf1_login/AreaProtection.java @@ -4534,7 +4534,6 @@ public class AreaProtection implements Listener { } - @EventHandler public void onExplosion(EntityExplodeEvent e) { Iterator it = e.blockList().iterator(); @@ -4548,6 +4547,26 @@ public class AreaProtection implements Listener { } } + // ===== 火床/烈焰弹/三叉戟闪电也拦截 ===== + @EventHandler + public void onBlockExplode(org.bukkit.event.block.BlockExplodeEvent e) { + for (Iterator it = e.blockList().iterator(); it.hasNext();) { + Block b = it.next(); + AreaConfig ac = getArea(b.getWorld().getName(), b.getX(), b.getY(), b.getZ()); + if (ac != null && ac.denyExplosion) it.remove(); + } + } + + @EventHandler + public void onEntityChangeBlock(org.bukkit.event.entity.EntityChangeBlockEvent e) { + // 拦截末影龙/末影螨改变方块(如把水变成源) + if (e.getBlock().getType() == Material.FIRE || e.getBlock().getType() == Material.LAVA) { + AreaConfig ac = getArea(e.getBlock().getWorld().getName(), + e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ()); + if (ac != null && ac.denyFire) e.setCancelled(true); + } + } + @EventHandler public void onInventoryOpen(InventoryOpenEvent e) { if (!(e.getPlayer() instanceof Player)) return; @@ -9512,9 +9531,12 @@ public class AreaProtection implements Listener { @EventHandler public void onIgnite(BlockIgniteEvent e) { Player p = e.getPlayer(); + Block tgtBlock = e.getBlock(); + AreaConfig srcArea = null; AreaConfig tgtArea = null; - // 检查源领地(玩家所在位置)和目标领地(被点燃方块位置) + + // 检查源领地(玩家所在位置) if (p != null) { srcArea = getArea( p.getWorld().getName(), @@ -9522,10 +9544,12 @@ public class AreaProtection implements Listener { p.getLocation().getBlockY(), p.getLocation().getBlockZ()); } - Block block = e.getBlock(); + + // 检查目标领地(被点燃方块位置) tgtArea = getArea( - block.getWorld().getName(), - block.getX(), block.getY(), block.getZ()); + tgtBlock.getWorld().getName(), + tgtBlock.getX(), tgtBlock.getY(), tgtBlock.getZ()); + // 任何一方denyFire=true就阻止 if ((srcArea != null && srcArea.denyFire) || (tgtArea != null && tgtArea.denyFire)) { e.setCancelled(true); @@ -9535,6 +9559,33 @@ public class AreaProtection implements Listener { } } + // ===== TNT自爆防漏网:EntityExplodeEvent ===== + @EventHandler + public void onEntityExplode(EntityExplodeEvent e) { + org.bukkit.entity.Entity ent = e.getEntity(); + if (ent != null) { + // 如果是TNT引爆,检查引爆位置 + AreaConfig ac = getArea(ent.getWorld().getName(), + (int) ent.getLocation().getBlockX(), + (int) ent.getLocation().getBlockY(), + (int) ent.getLocation().getBlockZ()); + // 如果爆炸源在禁止火焰蔓延的区域,取消所有爆炸 + if (ac != null && ac.denyFireSpread) { + e.blockList().clear(); + return; + } + } + // 检查每个被爆炸的方块是否在禁止爆炸的区域 + Iterator it = e.blockList().iterator(); + while (it.hasNext()) { + Block b = it.next(); + AreaConfig a = getArea(b.getWorld().getName(), b.getX(), b.getY(), b.getZ()); + if (a != null && a.denyExplosion) { + it.remove(); + } + } + } + // ===== 区域内方块着火(TNT、岩浆等)也阻止 ===== @EventHandler public void onBlockBurn(BlockBurnEvent e) {