diff options
author | KHobbits <rob@khobbits.co.uk> | 2011-10-24 15:37:44 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2011-10-24 15:37:44 +0100 |
commit | f843123f7e11240e68131350fd736255a96cc6e6 (patch) | |
tree | 491afb3a1b75877e6157a68d4a1d728c5ea95555 | |
parent | 443ae7fccec57b24aeb7eb02b449123afaea4d8d (diff) | |
download | Essentials-f843123f7e11240e68131350fd736255a96cc6e6.tar Essentials-f843123f7e11240e68131350fd736255a96cc6e6.tar.gz Essentials-f843123f7e11240e68131350fd736255a96cc6e6.tar.lz Essentials-f843123f7e11240e68131350fd736255a96cc6e6.tar.xz Essentials-f843123f7e11240e68131350fd736255a96cc6e6.zip |
AFK users shouldn't heal from full hunger.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 063a9d61b..4f8f2fa50 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -8,6 +8,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityListener; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; @@ -94,9 +96,18 @@ public class EssentialsEntityListener extends EntityListener { if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) { - //TODO: Remove the following line, when we're happy to remove backwards compatability with 1185. - event.setFoodLevel(20); event.setCancelled(true); } } + + public void onRegainHealth(EntityRegainHealthEvent event) + { + if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isAfk()) + { + if (event.getRegainReason() == RegainReason.SATIATED) + { + event.setCancelled(true); + } + } + } } |