From 4f2a0b8260d0ab8e531cf0dfbb6db3c55840e937 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 2 Mar 2012 09:35:52 -0800 Subject: [PATCH] Updating onEntityDamageByEntity event listener --- .../nossr50/listeners/mcEntityListener.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index b54ba39d3..73b802aaa 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -75,7 +75,21 @@ public class mcEntityListener implements Listener event.setCancelled(true); } - Combat.combatChecks(event, plugin); + //Check for mcgod mode + if(defender instanceof Player) + { + Player playerDefender = (Player)defender; + if(Users.getProfile(playerDefender).getGodMode()) + event.setCancelled(true); + } + + //Make sure defender is not invincible + if(defender instanceof LivingEntity) + { + LivingEntity livingDefender = (LivingEntity)defender; + if(livingDefender.getNoDamageTicks() < livingDefender.getMaximumNoDamageTicks()/2.0F) + Combat.combatChecks(event, plugin); + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)