From a4556e8cf0836b4c19738512526096c2420bf509 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 24 Oct 2011 15:37:44 +0100 Subject: AFK users shouldn't heal from full hunger. --- .../com/earth2me/essentials/EssentialsEntityListener.java | 15 +++++++++++++-- 1 file 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); + } + } + } } -- cgit v1.2.3