Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler(priority = EventPriority.MONITOR)
- public void onFoodLevelChange(FoodLevelChangeEvent e) {
- if(e.isCancelled()) return;
- if (!e.getEntity().getType().equals(EntityType.PLAYER)) return;
- Player pl = (Player)e.getEntity();
- if(!pl.hasPermission("wildfireclasses.getbenefits")) return;
- if(pl.getGameMode().equals(GameMode.CREATIVE)) return;
- String lname = pl.getName().toLowerCase();
- if(!plugin.getConfig().contains("userdb."+lname)) return;
- String path = "userdb."+lname+".";
- if(plugin.getConfig().getInt(path+"classid") != 4) return;
- int lvl = plugin.getLevelByXp(plugin.getConfig().getInt(path+"xp"));
- ItemStack food = e.getEntity().getItemInHand();
- int foodOld = pl.getFoodLevel();
- int foodNew = e.getFoodLevel() <= 20 ? e.getFoodLevel() : 20;
- //pl.sendMessage("You ate a " + food.getType().name() + " and went from " + foodOld + " to " + foodNew);
- if(lvl >= 3 && foodOld < foodNew){
- int h = (int) pl.getHealth(); // THIS IS LINE 212
- h += (foodNew - foodOld) / 2;
- if(h > 20) h = 20;
- pl.setHealth(h);
- if(d) pl.sendMessage(p + "Used ability: HealFromFood");
- }
- if(lvl >= 6){
- if(food.getType().equals(Material.GOLDEN_APPLE)){
- pl.setHealth(20);
- pl.setFoodLevel(20);
- if(d) pl.sendMessage(p + "Used ability: RestoreAllFromGoldApple");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement