Giving players health/p.damage in 1.6 HELP!

Discussion in 'Plugin Development' started by goomonster3, Jul 2, 2013.

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

    goomonster3

    Nothing is working, setting health and p.damage(ANY) is coming with a deprecated warning and getHealth coming up with the error: The method getHealth() is ambiguous for this type of Player.
    Please help,
    Thanks,
    Goo
     
  2. Offline

    Zarius

  3. Offline

    Rprrr

    Zarius
    So, how do we fix the ambiguity? I've not clue on how to do that.
     
  4. Offline

    Zarius

    Can you pastebin the code you have so far in that section?
     
  5. Offline

    Rprrr

    Zarius

    Code:
                            p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + "X" + ChatColor.GOLD + "] Max. health: " + p.getMaxHealth() + ".");
                            p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + "X" + ChatColor.GOLD + "] Current health: " + p.getHealth() + ".");
                            
    Not a paste bin, but.. it's just giving me ambiguity errors on every line that uses p.getMaxHealth(), p.getHealth(), et cetera. How can I tell Eclipse that I don't want to use the deprecated version of p.getMaxHealth() (that returns an integer value), but the new p.getMaxHealth() (that returns a double value)?
     
  6. Offline

    jayfella

    It won't matter because you're basically just calling ".toString()" on the value in those lines anyway. It will continue to work, even when the deceprecated methods are removed. The only ways to "force" it to use a double is assign the value of them to a variable:

    Code:java
    1. double maxHealth = p.getMaxHealth();
    2. double health = p.getHealth();

    then use those variable in your chat message. But, as I said, in this particular case, it makes absolutely no difference.

    Or you could use boxed conversion instead:

    Code:java
    1. (double)p.getMaxHealth();

    which is again, is nigh on pointless in this particular instance.
     
  7. Offline

    desht

    To those having problems: are you using Bukkit or CraftBukkit as your build dependency?
     
  8. Offline

    goomonster3

    CraftBukkit, I fixed the other error using doubles as Zarius said, thanks for that. But im trying to check a players health, I get an error with player.getHealth() .. I hate updates :p
     
  9. Offline

    IcyRelic

    I get the same error even with using it as a double in a variable
     
  10. Offline

    Wolvereness Bukkit Team Member

  11. Offline

    Datdenkikniet

    how do you convert an int to a double?
     
  12. Offline

    jayfella

    Double.ValueOf(int);
     
  13. Offline

    desht

    And there's your problem. Compile against Bukkit-1.6.1-R0.1-SNAPSHOT, and you'll be fine. Don't use CraftBukkit as a build dependency unless you're actually making NMS calls, and in that case be sure to specify Bukkit as a build dependency before CraftBukkit.

    It's very simple: build against the API, not the implementation.
     
  14. Offline

    InfamousSheep

    How does one do that? I am unsure.
     
  15. Offline

    desht

  16. Offline

    InfamousSheep

  17. Offline

    MP5K

  18. Offline

    AmShaegar

    Thanks for that. Did not think about that before. Reordering dependencies fixed all my problems.
    [​IMG]
     
  19. Offline

    Serilum

    Thanks guys, managed to get it working with your help :)
     
  20. Offline

    goomonster3

    Same ^^ Thanks.
     
  21. Offline

    FozZeW

    Bukkit.jar ???? what the hell, i only have craftbukkit. Where i can get that Bukkit.jar
     
  22. Offline

    kreashenz

    FozZeW I gave you a link before, check the other thread.. Stop reviving all of these threads.
     
Thread Status:
Not open for further replies.

Share This Page