Solved The method getHealth() is ambiguous for the type Player

Discussion in 'Plugin Development' started by Ambamore2000, Jan 2, 2014.

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

    Ambamore2000

    So, in the
    "healingPlayer.getHealth();
    " line, it keeps saying "The method getHealth() is ambiguous for the type Player".
    Help please
    Code:
    Code:java
    1. package me.Ambamore2000.UHCHG;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.entity.EntityRegainHealthEvent;
    13. import org.bukkit.event.player.PlayerItemConsumeEvent;
    14. import org.bukkit.inventory.ItemStack;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16.  
    17. public class Main extends JavaPlugin implements Listener{
    18.  
    19. Logger pluginLogger = Bukkit.getLogger();
    20. public Player theSender;
    21.  
    22. @Override
    23. public void onEnable(){
    24. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    25. pluginLogger.info(getName() + " has been enabled!");
    26. pluginLogger.warning("Enabling " + getName());
    27. }
    28. @Override
    29. public void onDisable(){
    30. pluginLogger.info(getName() + "has been disabled!");
    31. }
    32. @SuppressWarnings("deprecation")
    33. public boolean onCommand(CommandSender theSender, Command cmd, String commandLabel, String[] args) {
    34. if(cmd.getName().equalsIgnoreCase("uhcstart")){
    35. if (args.length >= 0);
    36. for(Player uhcPlayer : Bukkit.getServer().getOnlinePlayers()){
    37. uhcPlayer.setMaxHealth(40);
    38. uhcPlayer.setHealth(10);
    39. }
    40. }
    41. return false;
    42. }
    43. @EventHandler
    44. public void regenHealth(EntityRegainHealthEvent event) {
    45. event.setCancelled(true);
    46. }
    47. @EventHandler
    48. public void consumeItem(PlayerItemConsumeEvent event) {
    49. Player healingPlayer = (Player) theSender;
    50. ItemStack HEALTHPOT = new ItemStack(Material.POTION, 1, (short) 8197);
    51. if (event.getItem() == HEALTHPOT);{
    52. healingPlayer.getHealth();
    53. }
    54. }
    55. }

     
  2. Offline

    amhokies

    Ambamore2000
    Line 52 doesn't even do anything. It's returning the player's health, but not doing anything with it.
     
  3. Offline

    1Rogue Retired Staff

  4. Offline

    Ambamore2000

    1Rogue
    I've heard that SO MUCH TIMES, I don't get it. ;3 I'm serious. I don't get what you guys mean. Just use floats instead? What?
    amhokies
    I'm trying to MAKE it do something, but that is on a different thread.
     
  5. Offline

    AoH_Ruthless

    Ambamore2000
    Compile your plugin with the bukkit jar, not the craftbukkit jar. If you wish to use both, make sure the bukkit jar is above the craftbukkit jar in your build path.
     
  6. Offline

    Ambamore2000

    What bukkit.jar
     
  7. Offline

    AoH_Ruthless

    Ambamore2000
    The same exact place you downloaded the craftbukkit jar ....
     
  8. Offline

    Ambamore2000

    :O It's 'cause the video tut I watched said NO bukkit.jar. Makes more sence now. :D Thank you (P.S. What does bukkit.jar do with servers?)
     
  9. Offline

    AoH_Ruthless

  10. Offline

    Blingdaddy1

    Well technically, Bukkit is the API, and CraftBukkit is the server.
     
  11. Offline

    clienthax

    you can just cast the player to Damageable
     
Thread Status:
Not open for further replies.

Share This Page