The method getHealth() is ambiguous for the type LivingEntity

Discussion in 'Plugin Development' started by Kyozum0, Sep 4, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Kyozum0

    It gives me that error when i try to get plaer health
    The method getHealth() is ambiguous for the type LivingEntity
    Code:java
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent event) {
    3. Player p = event.getPlayer();
    4. ItemStack item = event.getItem();
    5. if (item != null && item.getType() == Material.MUSHROOM_SOUP && item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
    6. String name = item.getItemMeta().getDisplayName();
    7. int restores = 0;
    8. if (chocolateMilk && name.equals(chocolateMilkName))
    9. restores = mcpvp.getConfig().getInt("ChocolateMilkRestores");
    10. else if (cactusJuice && name.equals(cactusJuiceName))
    11. restores = mcpvp.getConfig().getInt("CactusJuiceRestores");
    12. if (restores != 0) {
    13. if (p.getHealth() < 20 || p.getFoodLevel() < 19) {
    14. event.setCancelled(true);
    15. if (p.getHealth() < 20)
    16. if (p.getHealth() + restores <= 20)
    17. p.setHealth(p.getHealth() + restores);
    18. else
    19. p.setHealth(20);
    20. else if (p.getFoodLevel() < 20)
    21. if (p.getFoodLevel() + restores <= 20)
    22. p.setFoodLevel(p.getFoodLevel() + restores);
    23. else
    24. p.setFoodLevel(20);
    25. if (item.getAmount() > 1) {
    26. item.setAmount(item.getAmount() - 1);
    27. HungergamesApi.getKitManager().addItem(p, new ItemStack(Material.BOWL));
    28. } else
    29. item = new ItemStack(Material.BOWL);
    30. p.setItemInHand(item);
    31. }
    32. }
    33. }
    34. }
    35.  
     
  2. Offline

    Tirelessly

  3. Offline

    Chinwe

  4. Offline

    Retherz_

    Remove CraftBukkit, import bukkit and then import craftbukkit
     
    Janmm14 likes this.
  5. Offline

    Kyozum0

    Still, i cant get the plyer heath because i cant put a "D" on p.getHealth(); like... p.getHealth(D);
     
  6. Offline

    Drkmaster83

    What IDE do you use?
     
  7. Offline

    Eballer48


    Because the method getHealth() doesn't call for any arguments...
     
Thread Status:
Not open for further replies.

Share This Page