Don't treat AFK players as god mode when dealing with food regen.

This commit is contained in:
KHobbits 2013-05-09 17:44:10 +01:00
parent 7051801a85
commit 59f67acfd0

View File

@ -170,12 +170,18 @@ public class EssentialsEntityListener implements Listener
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(final FoodLevelChangeEvent event) public void onFoodLevelChange(final FoodLevelChangeEvent event)
{ {
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) if (event.getEntity() instanceof Player)
{ {
final Player player = (Player)event.getEntity(); final User user = ess.getUser(event.getEntity());
player.setFoodLevel(20); if (user.isGodModeEnabled())
player.setSaturation(10); {
event.setCancelled(true); if (user.isGodModeEnabledRaw())
{
user.setFoodLevel(20);
user.setSaturation(10);
}
event.setCancelled(true);
}
} }
} }
@ -200,8 +206,9 @@ public class EssentialsEntityListener implements Listener
} }
} }
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityShootBow (EntityShootBowEvent event) public void onEntityShootBow(EntityShootBowEvent event)
{ {
if (event.getEntity() instanceof Player) if (event.getEntity() instanceof Player)
{ {