Renaming a Score in a Scoreboard?

Discussion in 'Plugin Development' started by Smartloser, Apr 18, 2014.

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

    Smartloser

    Hey guys. I made a plugin for my server that gets the online players in each server and displays them in the scoreboard that's in the hub. displaying the online players work, but whenever the online player count change (ex. another person joins the server) it makes another score.

    For example:
    I join the server, it displays:
    Online: 1

    If another guy joins the server, it displays:
    Online:1 (the one I had before)
    Online: 2 (the updated one).

    So, I was wondering how can I maybe rename the existing score so it wouldn't have to regenerate another score every time it updates.

    Thank you :)

    Regards,
    Smartloser
     
  2. Smartloser
    try using setScore(<int>); for the player amount.
     
  3. Offline

    Smartloser

    Hendrik_the_best I don't want to do that :p, I want the player count to be displayed in the scores name ;s
     
  4. If you're correctly using objective.getScore("Online") (or if below 1.7.8 - objective.getScore(Bukkit.getOfflinePlayer("Online"))) and using .setScore(x), it MUST work unless you're doing something very stupid... post code?
     
  5. Offline

    Smartloser

    I'm not trying to use the .setScore command, I am trying to put it inside the name, example: obj.getScore("Online: " + onlineplayers");
     
  6. Oh my god. (facepalm)

    This is how a scoreboard works:
    obj.getScore() is the name of the line, you need to use setScore() to set the number.

    Code:
    obj.getScore("Online:").setScore(onlineplayers);
     
  7. Offline

    NerdsWBNerds


    remove the previous score and add the new score, it's really the only way I know of.
     
  8. Offline

    Smartloser

    KingFaris11
    Again, I KNOW. I am trying to make a scoreboard like mineplex. I already got the title to work and everything else, but only this doesn't work. you see, I am trying to put the online players count INSIDE the line, not in the setscore. This is probably possible as mineplex does this just with letters and not numbers.

    This is my scoreboard:
    [​IMG]

    @NerdsWBNerds
    There must be another way as mineplex does it with their scoreboard..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  9. Store the old player count into a Map<String, Integer>, String being the server name. When the player count changes, use scoreboard.resetScores(Bukkit.getOfflinePlayer("Online: " + oldCount"))
     
  10. Offline

    NerdsWBNerds


    There is no other way, that's the way Mineplex does it, if you watch, occasionally you'll see the scoreboard create one before it removes one and the size will get bigger for a second.
     
    KingFaris11 likes this.
  11. Smartloser
    create a new scoreboard every time you need to update the score.
     
    KingFaris11 likes this.
  12. Offline

    NerdsWBNerds


    That is literally the most inefficient thing to do...
     
  13. Offline

    Smartloser

    It worked, thank you guys :)
     
Thread Status:
Not open for further replies.

Share This Page