Scoreboard Need Help

Discussion in 'Plugin Development' started by Jbitters3, Aug 7, 2014.

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

    Jbitters3

    The player health under their name is not displaying.

    Code:java
    1. public class Main extends JavaPlugin{
    2.  
    3. public void playerHealth(){
    4.  
    5. ScoreboardManager manager = Bukkit.getScoreboardManager();
    6. Scoreboard board = manager.getNewScoreboard();
    7.  
    8. Objective objective = board.registerNewObjective("showhealth", "health");
    9. objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
    10. objective.setDisplayName("/20");
    11.  
    12. for(Player online : Bukkit.getOnlinePlayers()){
    13. online.setScoreboard(board);
    14. online.setHealth(online.getHealth());
    15. }
    16. }
    17.  
    18.  
    19. }
     
  2. Offline

    fireblast709

  3. Offline

    Jbitters3

  4. Offline

    fireblast709

    Jbitters3 which is why it doesn't work :p. You wrote code that never gets executed.
     
  5. Offline

    Jbitters3

  6. Offline

    fireblast709

    Jbitters3 create a member variable in your main class for the Scoreboard, lines 5-10 in onEnable() (but assign board to the member variable you created) and line 13 and 14 in a PlayerJoinEvent handler (no for loop needed, just updating the joining player should be fine)
     
Thread Status:
Not open for further replies.

Share This Page