Solved Please help! player health

Discussion in 'Plugin Development' started by moneyremco, Sep 24, 2013.

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

    moneyremco

    hi there!
    i want to make it that if players in my minigame eat something they get a few health points, but how? i have this already:
    Code:java
    1. @EventHandler
    2. public void OnEat(PlayerInteractEvent e){
    3. Player player = e.getPlayer();
    4. if(!spelers.contains(player)){
    5. return;
    6. }
    7. if(spelers.contains(player)){
    8. if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
    9. double health = (double) e.getPlayer().getHealth();
    10. if(player.getItemInHand().equals(Material.APPLE) && ){
    11.  
    12. }
    13. }
    14. }
    15. }
    Somebody know?
     
  2. Offline

    TheDeathMachine

    you could maybe do player.setHealth(player.getHealth+2)
     
  3. Offline

    moneyremco

    Then i get this by player.getHealth+2:

    The method getHealth() is ambiguous for the type Player
     
  4. Offline

    TheDeathMachine

    mh, dont know about that, last time i treid it with player.setHealth(player.getHealth-2) it did work...
    But i think i found a bug, as soon as someone would right-clik he would directly get his health without his food being removed
     
  5. Offline

    Technes

    TheDeathMachine

    The method getHealth() is ambiguous in your situation because it has been changed from using integer values to double values.

    Try something along the lines of player.setHealth((player.getHealth) + 2.0D)

    EDIT: I'm not sitting at my computer right now, but you will be able to use either:
    "+ 2.0" or "+ 2D"
     
    moneyremco likes this.
  6. Offline

    moneyremco

    ty
     
  7. Offline

    TheDeathMachine

Thread Status:
Not open for further replies.

Share This Page