Unable to get Player's Health

Discussion in 'Plugin Development' started by jts3304, Jul 16, 2014.

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

    jts3304

    This problem affected my coding of a plugin, but I have found a fix for it:

    Since in my plugin I have a custom Player object called Person which basically extends Player so that I can add new methods.

    At the top of my Person class I made a variable declaration:
    Code:java
    1. private double damage;


    In my custom getHealth method I subtracted a number from 20 (a Player at full health):
    Code:java
    1. public double getHealth()
    2. {
    3. return 20-this.damage;
    4. }


    In that class I made an @EventHandler that detects when an entity damages another entity:
    Code:java
    1. @EventHandler
    2. public void onPlayerDamage(EntityDamageByEntityEvent event)
    3. {
    4. this.damage = event.getDamage();
    5. }


    So this is how I fixed this problem.
     
  2. Offline

    Jogy34

    Really? This thread is over a year old, the last post on it before the one you just posted, is over a year old. You had no reason to post that on this thread. Please don't necro. it's really annoying.
     
  3. Offline

    jts3304

    I looked on bukkit at threads about this problem because I didn't know how to fix it, but when I was looking at the comments i figured out how to fix it. So i posted the way I did it. This thread helped me.
     
  4. I was reading the post like, hmm, a fresh new thread about someone who can't even health!
    *reads last post*
    *looks at dates*
    oh. Old thread is old. darn.
     
  5. Offline

    TnT Retired Staff

    Moved this thread to its own post. In the future jts3304, start a new post stating your problem. You'll get further ahead than posting on a long dead thread.
     
  6. Offline

    jts3304

    I didn't realize this thread was dead. I'm sorry, I will look next time :) TnT Jogy34
     
Thread Status:
Not open for further replies.

Share This Page