diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-09-28 20:55:37 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-09-28 20:56:03 +0100 |
commit | c0a176825ce6596968904ee875292e076552b936 (patch) | |
tree | 859d5588a0cac62e6490ddf7c730fd7d52390731 | |
parent | db6512b70258845ebcc9c81db7fb8ae9f61797a5 (diff) | |
download | Essentials-c0a176825ce6596968904ee875292e076552b936.tar Essentials-c0a176825ce6596968904ee875292e076552b936.tar.gz Essentials-c0a176825ce6596968904ee875292e076552b936.tar.lz Essentials-c0a176825ce6596968904ee875292e076552b936.tar.xz Essentials-c0a176825ce6596968904ee875292e076552b936.zip |
Add potion effect clearing on /heal - Chris Ward
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java | 12 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandheal.java | 21 |
2 files changed, 18 insertions, 15 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 0dfff355c..0077d988c 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -15,8 +15,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.*; import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; public class EssentialsEntityListener implements Listener @@ -170,14 +168,10 @@ public class EssentialsEntityListener implements Listener { for (LivingEntity entity : event.getAffectedEntities()) { - if (entity instanceof Player) + if (entity instanceof Player && ess.getUser(entity).isGodModeEnabled()) { - User user = ess.getUser(entity); - if (user.isGodModeEnabled()) - { - event.setIntensity(entity, 0d); - } + event.setIntensity(entity, 0d); } } } -} +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java index 82678c96e..224e782de 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java @@ -6,6 +6,8 @@ import java.util.List; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class Commandheal extends EssentialsCommand @@ -33,9 +35,7 @@ public class Commandheal extends EssentialsCommand { user.healCooldown(); } - user.setHealth(20); - user.setFoodLevel(20); - user.sendMessage(_("heal")); + healPlayer(user); } @Override @@ -63,10 +63,19 @@ public class Commandheal extends EssentialsCommand { continue; } - p.setHealth(20); - p.setFoodLevel(20); - p.sendMessage(_("heal")); + healPlayer(p); sender.sendMessage(_("healOther", p.getDisplayName())); } } + + private void healPlayer(final Player p) + { + p.setHealth(20); + p.setFoodLevel(20); + p.sendMessage(_("heal")); + for (PotionEffect effect : p.getActivePotionEffects()) + { + p.removePotionEffect(effect.getType()); + } + } } |