diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index 4415a64a2..66c2e31e8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -33,6 +33,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.Combat; @@ -239,6 +240,48 @@ public class mcEntityListener implements Listener } } + @EventHandler (priority = EventPriority.MONITOR) + public void onFoodLevelChange(FoodLevelChangeEvent event) + { + if(event.getEntity() instanceof Player) + { + Player player = (Player) event.getEntity(); + PlayerProfile PP = Users.getProfile(player); + int currentFoodLevel = player.getFoodLevel(); + int newFoodLevel = event.getFoodLevel(); + + if(newFoodLevel > currentFoodLevel) + { + int food = player.getItemInHand().getTypeId(); + + if(food == 297 || food == 357 || food == 360 || food == 282) + { + int foodChange = newFoodLevel - currentFoodLevel; + int herbLevel = PP.getSkillLevel(SkillType.HERBALISM); + + if(herbLevel < 200) + foodChange = foodChange + 1; + if(herbLevel >= 200 || herbLevel < 400) + foodChange = foodChange + 2; + if(herbLevel >= 400 || herbLevel < 600) + foodChange = foodChange + 3; + if(herbLevel >= 600 || herbLevel < 800) + foodChange = foodChange + 4; + if(herbLevel >= 800 || herbLevel < 1000) + foodChange = foodChange + 5; + if(herbLevel >= 1000) + foodChange = foodChange + 6; + + newFoodLevel = currentFoodLevel + foodChange; + if(newFoodLevel > 20) + event.setFoodLevel(20); + if(newFoodLevel <= 20) + event.setFoodLevel(newFoodLevel); + } + } + } + } + public boolean isBow(ItemStack is){ if (is.getTypeId() == 261){ return true;