From 882a457484a1cbfe37c65fac1780cf5176bdf4e7 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 2 Mar 2012 12:19:53 -0500 Subject: [PATCH] Listen to EntityDamageByEntity subevents --- .../nossr50/listeners/mcEntityListener.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index 558fd7000..b54ba39d3 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -61,6 +61,23 @@ public class mcEntityListener implements Listener this.plugin = plugin; } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) + { + Entity defender = event.getEntity(); + Entity attacker = event.getDamager(); + + if(attacker instanceof Player && defender instanceof Player) + { + if(!defender.getWorld().getPVP()) + return; + if(Party.getInstance().inSameParty((Player)defender, (Player)attacker)) + event.setCancelled(true); + } + + Combat.combatChecks(event, plugin); + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { @@ -68,24 +85,6 @@ public class mcEntityListener implements Listener EntityType type = entity.getType(); DamageCause cause = event.getCause(); - //Check for world pvp flag - if(event instanceof EntityDamageByEntityEvent && !event.isCancelled()) - { - EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event; - Entity defender = eventb.getEntity(); - Entity attacker = eventb.getDamager(); - - if(attacker instanceof Player && defender instanceof Player) - { - if(!entity.getWorld().getPVP()) - return; - if(Party.getInstance().inSameParty((Player)defender, (Player)attacker)) - event.setCancelled(true); - } - - Combat.combatChecks(eventb, plugin); - } - switch(type) { case PLAYER: @@ -106,6 +105,7 @@ public class mcEntityListener implements Listener if(!event.isCancelled() && event.getDamage() >= 1) PP.setRecentlyHurt(System.currentTimeMillis()); } + case WOLF: Wolf wolf = (Wolf) entity; if((wolf.getNoDamageTicks() < wolf.getMaximumNoDamageTicks()/2.0F) && wolf.isTamed() && wolf.getOwner() != null)