From 41f31250a9f1500a165377c2a9029ad132251e55 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Sat, 24 Dec 2011 22:49:26 -0800 Subject: [PATCH] Added support for fireballs shot by players being blocked by the PVP flag. --- .../bukkit/WorldGuardEntityListener.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java index 053af57e..c34f8ed2 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java @@ -323,13 +323,24 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) { return; } if (wcfg.useRegions) { + Fireball fireball = (Fireball) attacker; Vector pt = toVector(defender.getLocation()); RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld()); ApplicableRegionSet set = mgr.getApplicableRegions(pt); - if (!set.allows(DefaultFlag.GHAST_FIREBALL)) { - event.setCancelled(true); - return; + if (fireball.getShooter() instanceof Player) { + Vector pt2 = toVector(fireball.getShooter().getLocation()); + if (!set.allows(DefaultFlag.PVP) || !mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP)) { + ((Player) fireball.getShooter()).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area."); + event.setCancelled(true); + return; + } + } else { + if (!set.allows(DefaultFlag.GHAST_FIREBALL)) { + event.setCancelled(true); + return; + } } + } }