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 | a4556e8cf0836b4c19738512526096c2420bf509 (patch) | |
tree | 93c607a88d514d1456a4db09a14cc3f49385db03 | |
parent | 6974abea28233fd6118567841dad4e3af0a43d4b (diff) | |
download | Essentials-a4556e8cf0836b4c19738512526096c2420bf509.tar Essentials-a4556e8cf0836b4c19738512526096c2420bf509.tar.gz Essentials-a4556e8cf0836b4c19738512526096c2420bf509.tar.lz Essentials-a4556e8cf0836b4c19738512526096c2420bf509.tar.xz Essentials-a4556e8cf0836b4c19738512526096c2420bf509.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); + } + } + } } |