Trouble Displaying Health

Discussion in 'Plugin Development' started by Snacka Mooni, Jul 24, 2013.

?

Am is this easy to fix?

Poll closed Jul 31, 2013.
  1. Yes

    100.0%
  2. No

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    Snacka Mooni

    So, after the 1.6.1 update to Minecraft with health, I no longer know how to do this new thing. It used to be int's which were easy, but now they're doubles and I'm confused.

    Here's the code I've made, but I'm getting an error under online.getHealth();
    Error: "The method getHealth() is ambiguous for the type Player"

    Code:java
    1. @Override
    2. public void onEnable() {
    3. PluginDescriptionFile pdfFile = this.getDescription();
    4. this.logger.info(pdfFile.getName() + " V" + pdfFile.getVersion() + " Has been enabled!");
    5.  
    6. ScoreboardManager manager = Bukkit.getScoreboardManager();
    7. Scoreboard board = manager.getNewScoreboard();
    8.  
    9. Objective obj = board.registerNewObjective("showhealth", "health");
    10. obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
    11. obj.setDisplayName("/20 " + ChatColor.RED + "Hearts");
    12.  
    13. for(Player online : Bukkit.getOnlinePlayers()) {
    14. online.setScoreboard(board);
    15. online.setHealth(online.getHealth());
    16. }
    17.  
    18. CityJobs = Bukkit.createInventory(null, 18, "Job Selection");
    19.  
    20. ItemStack Chef = new ItemStack(Material.BREAD, 1);
    21. ItemMeta meta = Chef.getItemMeta();
    22. ArrayList<String> lore = new ArrayList<String>();
    23. meta.setDisplayName("Chef");
    24. lore.add("Feed hungry people");
    25. meta.setLore(lore);
    26. Chef.setItemMeta(meta);
    27.  
    28. CityJobs.setItem(0, new ItemStack(Chef));
    29.  
    30. getServer().getPluginManager().registerEvents(this, this);
    31. }


    Sorry if my code is all messy.. Just the way I code :/
     
  2. Offline

    ZeusAllMighty11 Retired Staff

    Compile against Bukkit
     
  3. Offline

    xTrollxDudex

    TheGreenGamerHD
    Wait everyone references CraftBukkit for coding purposes?
     
  4. Offline

    ZeusAllMighty11 Retired Staff

    xTrollxDudex

    This person may be compiling against both, but I assume only Craftbukkit.
    I don't understand your question. :\

    I used to reference all of my stuff with CraftBukkit, but I only ever needed it 1-3 times.
     
  5. Offline

    xTrollxDudex

    TheGreenGamerHD
    Does the majority of Bukkit programmers reference CraftBukkit instead of Bukkit?
    I always use Bukkit, am I an outcast?
     
    Tarestudio likes this.
  6. Offline

    Tarestudio

    xTrollxDudex
    I also reference Bukkit only. You ar not alone ;)
     
    xTrollxDudex likes this.
  7. Offline

    mollekake

    I was doing it myself. I switched to it when i needed som NMS coding, and didn't switch back because i saw no reason to.
     
  8. Offline

    Snacka Mooni


    I'm a bit confused. How exactly would I compile against Bukkit?
     
  9. Offline

    redytedy

  10. Offline

    xTrollxDudex

  11. Offline

    Snacka Mooni

    Thanks guys! :))))))
     
  12. Offline

    xTrollxDudex

Thread Status:
Not open for further replies.

Share This Page