How can I check if player is dead.

Discussion in 'Plugin Development' started by Pr07o7yp3, Feb 18, 2013.

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

    Pr07o7yp3

    Hi, I want to check if player is dead.
    For example I have a scheduler and I want to get only dead players.

    I tried with player.isDead() but I think it doesn't work correctly.
    Is there any other way?
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    Pr07o7yp3
    There are currently no issues known with player's isDead method.
     
  3. Offline

    Pr07o7yp3

    Hmm, I'll try it again.
     
  4. Offline

    WiseHollow

    Depends on if you are checking isDead before the damage is done. For example on a entity damage listener. Pretty sure the event passes beforehand. So you'd need to run the check with something like..
    Code:
    if (event.getPlayer().getHealth - event.getDamage() <= 0)
    {
        // Do this
    }
    Could be wrong, but just wanted to throw that out there xD
     
  5. Offline

    Jozeth

    Use EntityDeathEvent, check if it's a player and then do what you want.

    Such as: Once they die save them in a hashmap or file, etc... so you can check if they've died.
     
Thread Status:
Not open for further replies.

Share This Page