Scoreboard problem/bug

Discussion in 'Spigot Plugin Development' started by ErbenV, Apr 24, 2017.

  1. Hii guys,

    Before you start reading: Sorry for my bad english :)

    I was coding a scoreboard and it was going well, first a made it without an update system and you would see you're new rank only if you relogged, now i made it with an update system but it keeps displaying the old AND the new rank? Pls help

    Source:
    https://pastebin.com/6Kst4nXw

    Screens:
    No rank change: https://gyazo.com/c38e1d69f0500b79e75e8c3983e3625a
    With rank change: https://gyazo.com/a78b5584451ffb5acad93f8a0489a3a9

    Can someone help me?
    Thnx, Erben.
     
  2. You should only change what might change (move lines 30-37 to line 26 for example, because they won't change - as far as I know at least).

    The scoreboard is designed for players. Alice and Bob can both have 5 kills, so both of them should be displayed. What I mean by that, is that just because two entries have the same score (8 in this case), the old one won't be overwritten.

    I don't know what is the best way to solve your issue, but you could probably save the player's last rank and use the resetScores(String entry) method. Or you could loop through all entries using this method and check the scores.

    EDIT: also, are you sure you want to update the scoreboards every second tick? Isn't that a big too frequent for something like this?
     
    • Like Like x 1
  3. I don't really understand what you're saying, can you work it out for me? Thnx, Erben! :)
     
  4. I had the exact same problem. I ended up unregistering the SIDEBAR.

    This is what I did:
    Code (Text):

    Scoreboard board = get(p);
    if (board.getObjective(p.getName()) != null) {
          board.getObjective(p.getName()).unregister();
    }

    board.registerNewObjective(p.getName(), "dummy");
    board.getObjective(p.getName()).setDisplaySlot(DisplaySlot.SIDEBAR);