From c9a3d24e64dedf365b2dfbe675a38a85e3d4f841 Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Thu, 2 Jul 2026 21:58:19 +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=96=B0=E5=A2=9EPlayerInt?= =?UTF-8?q?eractEvent=E6=8B=A6=E6=88=AA=E6=89=93=E7=81=AB=E7=9F=B3/?= =?UTF-8?q?=E7=81=AB=E7=90=83/=E7=81=AB=E7=84=B0=E5=BC=B9=EF=BC=8CProjecti?= =?UTF-8?q?leHitEvent=E6=8B=A6=E6=88=AA=E7=83=88=E7=84=B0=E7=90=83?= =?UTF-8?q?=E8=90=BD=E5=9C=B0=EF=BC=8C=E5=BD=BB=E5=BA=95=E5=85=B3=E9=97=AD?= =?UTF-8?q?TNT/=E7=AF=9D=E7=81=AB=E7=82=B9=E7=87=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Sdf1_login/AreaProtection.java | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/main/java/Sdf1_login/AreaProtection.java b/src/main/java/Sdf1_login/AreaProtection.java index 85fac94..d34f7db 100644 --- a/src/main/java/Sdf1_login/AreaProtection.java +++ b/src/main/java/Sdf1_login/AreaProtection.java @@ -9559,6 +9559,57 @@ public class AreaProtection implements Listener { } } + // ===== 玩家使用打火石/点燃物品时直接拦截 ===== + @EventHandler + public void onPlayerInteractFire(PlayerInteractEvent e) { + Player p = e.getPlayer(); + Action action = e.getAction(); + Material mat = e.getItem() == null ? null : e.getItem().getType(); + + // 只拦截 RIGHT_CLICK_BLOCK/AIR 使用打火石/火床/TNT + if (action != Action.RIGHT_CLICK_BLOCK && action != Action.RIGHT_CLICK_AIR) return; + if (mat != Material.FLINT_AND_STEEL && mat != Material.FIRE_CHARGE && mat != Material.CAMPFIRE && mat != Material.SOUL_CAMPFIRE) { + // 如果是打火石或火球,检查使用的物品 + if (mat != Material.TNT) return; + } + + // 检查目标方块或玩家所处领地 + Block clickedBlock = e.getClickedBlock(); + AreaConfig ac1 = null; + AreaConfig ac2 = null; + + // 玩家位置 + ac1 = getArea(p.getWorld().getName(), + p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()); + + // 点击的方块 + if (clickedBlock != null) { + ac2 = getArea(clickedBlock.getWorld().getName(), + clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); + } + + if ((ac1 != null && ac1.denyFire) || (ac2 != null && ac2.denyFire)) { + e.setCancelled(true); + p.sendMessage("§c§l[区域防护] §f此区域禁止点燃物品"); + } + } + + // ===== 火焰弹/烈焰球拦截 ===== + @EventHandler + public void onProjectileHitFireball(ProjectileHitEvent e) { + if (!(e.getEntity() instanceof org.bukkit.entity.Fireball)) return; + org.bukkit.entity.Fireball fb = (org.bukkit.entity.Fireball) e.getEntity(); + AreaConfig ac = getArea(fb.getWorld().getName(), + fb.getLocation().getBlockX(), fb.getLocation().getBlockY(), fb.getLocation().getBlockZ()); + if (ac != null && ac.denyFire) { + fb.remove(); + // 如果射手是玩家,发消息 + if (fb.getShooter() instanceof Player) { + ((Player) fb.getShooter()).sendMessage("§c§l[区域防护] §f此区域禁止投掷火焰"); + } + } + } + // ===== TNT自爆防漏网:EntityExplodeEvent ===== @EventHandler public void onEntityExplode(EntityExplodeEvent e) {