Player get Health & get How much Soups he had in he's HotBar

Discussion in 'Plugin Development' started by DeStickyOne, Jan 10, 2014.

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

    DeStickyOne

    Hey Hey Hey !
    i wanna make a PlayerDeathevent
    so its will send the Killer
    e.getentity.getkiller
    Thats he killed e.getentity.getname
    or if (e.getentity instanceof Player)
    Player p = (Player) e.getentity

    i wanna send him how much soups he got in he's hotbar
    how can i get Thats?
    and i wanna send him how much hearts he got ?

    double de = p.gethealth
    not working
     
  2. Offline

    GaaTavares

    It looks your trying to do a 1v1 plugin
    Dude first you should look at bukkit's javadocs, it could solve your problem..
    getting health: p.getHealth();
    getting soups:
    int soups = 0;
    Code:java
    1. for (ItemStack is : p.getInventory().getContents()){
    2. if (is != null && is.getType() == Material.MUSHROOM_SOUP){
    3. soups++;
    4. }
    5. }
     
  3. umm... Could you please send us your code / error log / more details if any? We couldn't help much without them.
     
  4. Offline

    GaaTavares

    Why isn't working? It works fine.. p.getHealth() returns a double.
     
  5. Offline

    DeStickyOne

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

    GaaTavares

    Use bukkit, not craftbukkit
     
  7. Offline

    werter318

    GaaTavares
    If he wants to use craftbukkit, he could always use ((CraftPlayer) player).getHealth();
     
  8. Offline

    GaaTavares

    Yes but using bukkit is better than using craftbukkit (even Staff members allow with that)
     
    werter318 likes this.
  9. Offline

    GeorgeMarx

    Thanks so much i just found your post and my god you saved me
     
  10. Offline

    qlimax5000

    GeorgeMarx
    The CraftPlayer import changes each update, so unless you wanna force yourself to update each time then use

    ((Damageable) player).getHealth();
     
  11. Offline

    GeorgeMarx

    Thanks also is it wise to just make the move to normal bukkit instead of craftbukkit?
    EDIT
    moved to spiggot so using bukkit not craft bukkit but
    ((Damageable) player).getHealth();
    still works so cheers
     
Thread Status:
Not open for further replies.

Share This Page