Advertisement
rsod

Untitled

Aug 4th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.MONITOR)
  2. public void onFoodLevelChange(FoodLevelChangeEvent e) {
  3. if(e.isCancelled()) return;
  4. if (!e.getEntity().getType().equals(EntityType.PLAYER)) return;
  5. Player pl = (Player)e.getEntity();
  6. if(!pl.hasPermission("wildfireclasses.getbenefits")) return;
  7. if(pl.getGameMode().equals(GameMode.CREATIVE)) return;
  8. String lname = pl.getName().toLowerCase();
  9. if(!plugin.getConfig().contains("userdb."+lname)) return;
  10. String path = "userdb."+lname+".";
  11. if(plugin.getConfig().getInt(path+"classid") != 4) return;
  12. int lvl = plugin.getLevelByXp(plugin.getConfig().getInt(path+"xp"));
  13.  
  14. ItemStack food = e.getEntity().getItemInHand();
  15. int foodOld = pl.getFoodLevel();
  16. int foodNew = e.getFoodLevel() <= 20 ? e.getFoodLevel() : 20;
  17.  
  18. //pl.sendMessage("You ate a " + food.getType().name() + " and went from " + foodOld + " to " + foodNew);
  19.  
  20. if(lvl >= 3 && foodOld < foodNew){
  21. int h = (int) pl.getHealth(); // THIS IS LINE 212
  22. h += (foodNew - foodOld) / 2;
  23. if(h > 20) h = 20;
  24. pl.setHealth(h);
  25. if(d) pl.sendMessage(p + "Used ability: HealFromFood");
  26. }
  27.  
  28. if(lvl >= 6){
  29. if(food.getType().equals(Material.GOLDEN_APPLE)){
  30. pl.setHealth(20);
  31. pl.setFoodLevel(20);
  32. if(d) pl.sendMessage(p + "Used ability: RestoreAllFromGoldApple");
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement