Solved player.getHealth(), no work

Discussion in 'Plugin Development' started by LeonTG77, Aug 13, 2014.

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

    LeonTG77

    Title explains, i need help how to fix player.getHealth()
     
  2. Offline

    mythbusterma

    LeonTG77

    The function works, you're just doing something wrong. What are you doing wrong?
     
  3. Offline

    Dubehh

  4. Offline

    LeonTG77

    I may or may not have deleted the code of rage :p
    I tried floats, ints and doubles, nope, doesnt work
     
  5. LeonTG77 Did you get errors? Did your server kick you? Did nothing happen? Did it start calculating digits of pi?
     
  6. Offline

    LeonTG77

    If i just use player.getHealth(), The method getHealth() is ambiguous for the type Player http://gyazo.com/e047a1679d2a4e81a3a5f0389e91d60c
    Same if i do (double) or (float)'s
     
  7. Offline

    ZodiacTheories

    AdamQpzm

    Why would it calculate digits of PI?
     
  8. ZodiacTheories Because it was the first ridiculous activity that came to mind when I was trying to demonstrate that it's not helpful when we don't know what's wrong :)

    LeonTG77 Official: http://forums.bukkit.org/threads/oops-i-didnt-break-your-plugins-ambiguous-gethealth.156975

    Other:
    http://forums.bukkit.org/threads/calling-livingentity-getmaxhealth-makes-compilation-error.302253/
    http://forums.bukkit.org/threads/running-into-a-ambigous-gethealth-prolblem-is-there-a-fix.299984
    http://forums.bukkit.org/threads/player-gethealth-not-working.294791
    https://forums.bukkit.org/threads/ambiguous-method-call.290605/
    http://forums.bukkit.org/threads/gethealth.276919/
    http://forums.bukkit.org/threads/ambiguous-method-call-help.259542/
    http://forums.bukkit.org/threads/player-gethealth-in-a-event.252147
    http://forums.bukkit.org/threads/adding-health.249685/
    http://forums.bukkit.org/threads/adding-to-player-health.248607
    http://forums.bukkit.org/threads/gethealth-help.240372/
    http://forums.bukkit.org/threads/help-please.237838/
    http://forums.bukkit.org/threads/gethealth-is-ambiguous.231921/
    http://forums.bukkit.org/threads/gethealth-is-ambiguous.228237/
    http://forums.bukkit.org/threads/gethealth.227353
    http://forums.bukkit.org/threads/gaining-health.222595
    http://forums.bukkit.org/threads/player-getmaxhealth-problem.218817/
    http://forums.bukkit.org/threads/player-get-health-get-how-much-soups-he-had-in-hes-hotbar.218264
    http://forums.bukkit.org/threads/add-health-instead-of-setting-it.129058
    http://forums.bukkit.org/threads/gethealth-is-ambiguous-for-the-type-player.215698/
    http://forums.bukkit.org/threads/the-method-gethealth-is-ambiguous-for-the-type-player.214760/
    http://forums.bukkit.org/threads/help-with-my-plugin-wont-get-player-health.212361/
    http://forums.bukkit.org/threads/delay-on-command.211452
    http://forums.bukkit.org/threads/snowball-damage.209423
    http://forums.bukkit.org/threads/land-mines-doesnt-cause-player-damage.208364
    http://forums.bukkit.org/threads/target-gethealth-error.208123
    http://forums.bukkit.org/threads/getting-player-health.204195
    http://forums.bukkit.org/threads/gethealth-getmaxhealth.200176/
    http://forums.bukkit.org/threads/slenderman-plugin-errors.195214/
    http://forums.bukkit.org/threads/two-different-gethealth-methods-in-code.194860/
    http://forums.bukkit.org/threads/mob-health.194295
    http://forums.bukkit.org/threads/right-click-on-item.193745
    http://forums.bukkit.org/threads/p-gethealth-error.193150
    http://forums.bukkit.org/threads/events-not-fired-foodlevelchangeevent.191799
    http://forums.bukkit.org/threads/gethealth-isnt-working.184244/
    http://forums.bukkit.org/threads/healing-problems.182755
    http://forums.bukkit.org/threads/please-help-player-health.176919
    http://forums.bukkit.org/threads/ambiguous-gethealth.176704/
    http://forums.bukkit.org/threads/double-hp-player-gethealth.175774
    http://forums.bukkit.org/threads/instant-soup-plugin-help.175203/
    http://forums.bukkit.org/threads/gethealth-problem.172985/
    http://forums.bukkit.org/threads/the-method-gethealth-is-ambiguous-for-the-type-livingentity.172649/
    http://forums.bukkit.org/threads/soup-plugin-trouble.171039/
    http://forums.bukkit.org/threads/checking-health.169234
    http://forums.bukkit.org/threads/gethealth-and-getmaxhealth-is-ambiguous.168384/
    http://forums.bukkit.org/threads/i-still-dont-understand-this-livingentitys-gethealth.166316/
    http://forums.bukkit.org/threads/gethealth.164234
    http://forums.bukkit.org/threads/trouble-displaying-health.162284
    http://forums.bukkit.org/threads/cant-use-bukkit-or-craftbukkit.161364
    http://forums.bukkit.org/threads/gethealth-not-working.161136
    http://forums.bukkit.org/threads/player-gethealth-wont-work-for-1-6.160857/
    http://forums.bukkit.org/threads/player-gethealth-1-6-2-problem.159547
    http://forums.bukkit.org/threads/lose-hearts-health-on-command.159632
    http://forums.bukkit.org/threads/a-fast-soup-problem.159522
    http://forums.bukkit.org/threads/adding-more-hearts-to-players.159191/
    http://forums.bukkit.org/threads/1-6-ambiguous-gethealth.158924
    http://forums.bukkit.org/threads/ambiguous-with-double.158182
    http://forums.bukkit.org/threads/gethealth-is-ambiguous.157851/
    http://forums.bukkit.org/threads/the-method-gethealth-is-ambiguous-for-the-type-player.157668/
    http://forums.bukkit.org/threads/1-6-1-gethealth-ambiguous.157592
    http://forums.bukkit.org/threads/health-is-ambiguous.157586/
    http://forums.bukkit.org/threads/gethealth-how-do-i-add-health-to-a-player.157398/
    http://forums.bukkit.org/threads/gethealth-1-6-1-change-help.157315/
    http://forums.bukkit.org/threads/unable-to-get-players-health.157229/
    http://forums.bukkit.org/threads/giving-players-health-p-damage-in-1-6-help.157063/
     
    mythbusterma and ZodiacTheories like this.
  9. Offline

    CullanP

    Code:
    Damageable dEntity = (Damageable)player;
    player is the variable you should use, you can change it to p or whatever, but this will fix your ambiguous issue.

    Use dEntity.getHealth() and tell me if that works.
     
    LeonTG77 likes this.
  10. Offline

    ZodiacTheories

  11. Offline

    LeonTG77

    Thanks
     
  12. Offline

    FabeGabeMC

    LeonTG77
    do ((Damageable)player).getHealth();
    as CullanP said.
    In other words... :p
     
  13. Offline

    mythbusterma

    LeonTG77

    Despite the fact you obviously didn't search Google or even look at the top of the forum page for the stickied thread with " - ambiguous getHealth()" in the name. Furthermore, that isn't even the best solution, instead, don't include CraftBukkit when you don't need it, and you won't have this problem.
     
    AdamQpzm likes this.
  14. Offline

    Chiller

    LeonTG77 You really should be including Bukkit not Craftbukkit...
     
Thread Status:
Not open for further replies.

Share This Page