player.getHealth() in a event?

Discussion in 'Plugin Development' started by Hendrik_the_best, Apr 3, 2014.

Thread Status:
Not open for further replies.
  1. player.getHealth/event.getPlayer().getHealth() is not working for me in a event or i do something wrong please help me :p

    ( im tring to do player.setHealth(player.getHealth() - 1); )
  2. Offline


  3. bballheat
    when i go with my mouse over the player.setHealth(player.getHealth() - 1); it says this: The method getHealth() is ambiguous for the type Player
  4. Offline


    Import bukkit then craftbukkit
    The Fancy Whale likes this.
  5. Offline


  6. Offline

    The Fancy Whale

  7. Offline


    You need to cast it to a damageable
    Player player = event.getPlayer();
    Damageable dam = (Damageable) player;

    should work

    player.setHealth(dam.getHealth() - 1);
  8. Offline


    I usually add the 1.5 bukkit jar. Not sure if its the most efficient way to do it but it works.
  9. Offline


    dam, never seen that before.

    (sorry, bad joke aimed at your variable)
  10. thanks for all the help guys!
    got it to work
Thread Status:
Not open for further replies.

Share This Page