Solved Health is ambiguous?

Discussion in 'Plugin Development' started by i3ick, Jul 4, 2013.

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

    i3ick

    Hey after the update it seems that some of my code stopped working. It says the health is ambiguous. What do I have to do to fix this?
    Here is the code, it basically saves the player location if he has less then one and a half heart but getHealth is underlined and setHealth is stroken through.

    Code:
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onPlayerDamage(EntityDamageEvent event){
            if (event.getEntity() instanceof Player){
                Player player = (Player) event.getEntity();
                if(plugin.ftagplayers.contains(player.getName())){
                if(player.getHealth() < 3){
                    player.getLocation();
                    player.setHealth(20);
                    player.getInventory().setHelmet(new ItemStack(Material.ICE,1));
                    plugin.frozen.add(player.getName());
                    plugin.getConfig().set(player.getName() + ".X", player.getLocation().getBlockX());
                    plugin.getConfig().set(player.getName() + ".Y", player.getLocation().getBlockY());
                    plugin.getConfig().set(player.getName() + ".Z", player.getLocation().getBlockZ());
                    plugin.getConfig().options().copyDefaults(true);
                      plugin.saveConfig();
                    player.sendMessage(ChatColor.YELLOW + "position saved");
                    }
               
                }
            }   
        }
    Thanks for your help,
    i3ick
     
  2. Offline

    LimaSxD

    Try player.setHealth(20.0);
     
  3. Offline

    kreashenz

    i3ick Use .setHealth(20.0); as it's now doubles, not integers. For the ambiguous thing, there was another thread on this, and the person just moved their Bukkit under their Craftbukkit (If they using both) in the Order and Export tab in properties (Eclipse).
     
  4. Offline

    i3ick

    Thanks, it worked!
     
  5. Offline

    xWatermelon

    i3ick kreashenz I only have craftbukkit.jar in the build path (no Bukkit.jar) and I still have this problem. How can I fix it?
     
  6. Offline

    kreashenz

    xWatermelon Import Bukkit.jar especially if you're not using any NMS/OCB. I prefer adding both anyway, dunno why.
     
  7. Offline

    stirante

    kreashenz Is there a way to use getHealth now?
     
  8. Offline

    jayfella

    its still there, its just ambiguous because there are "two versions" of it - and int and a double - to enable old plugins to work. Just use a double as everyone mentioned, instead of an int.
     
  9. Offline

    TheA13X

    wait. Whats the Bukkit.jar? I just HAVE the craftbukkit.jar. Did i miss something?
     
    FozZeW likes this.
Thread Status:
Not open for further replies.

Share This Page