Scoreboard

Discussion in 'Plugin Development' started by TerroDoor, Nov 27, 2019.

  1. Offline

    TerroDoor

    Hey! So I’ve got a scoreboard up and running, it displays all my kills etc from the config so I know that it is working. However, I was reading up on updating a scoreboard and apparently the only way is with a runnable? I tried that but didn’t succeed and it was flashing the scoreboard every tick


    Sent from my iPhone using Tapatalk
     
  2. Online

    timtower Moderator Moderator

    @TerroDoor Don't create a new scoreboard, re-use the old one.
     
  3. Offline

    TerroDoor

    Thankyou, I’ll look into this shortly when I’m back with my laptop


    Sent from my iPhone using Tapatalk

    Okay so I’ve got it working but another problem has risen, it is rearranging my titles from highest to lowest in the scoreboard.

    I had it set in order from
    kills:
    deaths:
    streak:
    coins:

    EDIT:

    here's my code, its not being set in the order I want:

    Code:
    
     public void setScoreboard(Player p) {
     Scoreboard b = pl.getServer().getScoreboardManager().getNewScoreboard(); 
     Objective o = b.registerNewObjective("i dont", "understand this part but okay");
     
     int kills = pl.getConfig().getInt(p.getName() + ".kills");
     int deaths = pl.getConfig().getInt(p.getName() + ".deaths");
     int streak = pl.getConfig().getInt(p.getName() + ".streak");
     int bal = pl.getConfig().getInt(p.getName() + ".coins");
     Score killscore = o.getScore(ChatColor.GOLD + "Kills: " + kills);
     Score deathscore = o.getScore(ChatColor.GOLD + "Deaths: " + deaths);
     Score streakscore = o.getScore(ChatColor.GOLD + "Streak: " + streak);
     Score balance = o.getScore(ChatColor.GOLD + "Coins: " + bal);
     
     killscore.setScore(1);
     deathscore.setScore(2);
     streakscore.setScore(3);
     balance.setScore(4);
     
     o.setDisplayName(ChatColor.LIGHT_PURPLE + "www.jkits.org/donate");
     o.setDisplaySlot(DisplaySlot.SIDEBAR);
     
     p.setScoreboard(b);
     return;
    
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited: Nov 27, 2019
  4. Online

    timtower Moderator Moderator

    @TerroDoor They get ordered by score. That it how scoreboards work.
    Put the first one as the highest number.
     

Share This Page