Solved Removing scores.

Discussion in 'Plugin Development' started by StealWonders, Feb 4, 2016.

Thread Status:
Not open for further replies.
  1. How would I be able to remove the scores from the scoreboard before updating it so I don't get duplicate slightly changed texts?

    [​IMG]
     
  2. Offline

    GamerzKing

    Impossible.
     
  3. And how do other servers do it?

    I've tried this:
    Code:
    obj.getScoreboard().resetScores("scoreboard");
    but it only resets a score and not the
    scoreboard... Also if the amout of players online changes I wouldnt be able to put in the same code...
     
    Last edited by a moderator: Feb 4, 2016
  4. Offline

    teej107

    I don't remember exactly but setting the score to 0 may remove the entry.
     
  5. Offline

    Flaps

    When you send the initial string, store it.
    When you want to update the line, check if the initially stored string is not null and reset it, then set the the stored string variable as the updated string.

    OR

    Use my WIP scoreboard API, can be compiled in your Jar so people are not required to install it as a plugin: https://github.com/Alexandeh/Glaedr

    You can simply call a method to update a line and it'll all be handled for you.
     
    Sw_aG likes this.
  6. Thanks I'l try it and report back But how will I get the old score name? ;)

    Edit: Setting any score to "0" won't remove it.

    So you say I store the info in a hashmap or something and then reset the objective/score by getting this saved string
    by using objective.getScoreboard().resetScores(stored string); ???

    Hey,

    I am coding a tags plugin and I am stuck on making it check if the user has the permission to use that tag. The reason I am stuck is because it is configurable so I cannot hard-code the tag permissions ;-;

    CODE (open)

    code removed


    Thanks,
    _zircon_.

    EDIT: code removed;

    OMG another simple fix ;-; Sorry guys, it was a problem with PEX not removing the "*" permission

    Thanks.
    _zircon_.

    @timtower: Please lock the thread to prevent necroposting.
     
    Last edited by a moderator: Feb 6, 2016
    Sw_aG likes this.
  7. Offline

    Flaps

    Yeah, basically.

    Wouldn't work as scoreboards support negative scores too, as well as 0.
     
    Last edited by a moderator: Feb 6, 2016
  8. Sorry to ask, but I'm kinda new to everything: How would I do this. So I have a hashmap.
    Do I need to create a new hashmap for every objective/score I have? And when I have one
    do I save it like this? playername (Scoreboard name); "§7Online: §f§l" + CONFIG METHOD

    Edit: Maybe show some code ^^
     
  9. Offline

    Flaps

    Check out my scoreboard API for some example code. https://github.com/Alexandeh/Glaedr
    I create an Entry object that stores all the variables associated with ONE line on the scoreboard which I then interact with, etc. If you don't necessarily want to make a new object, then I would suggest using either a HashMap that stores a string and an integer(score), or a hashmap that stores a string and another object to be used to identify that string.
     
    StealWonders likes this.
  10. Offline

    Flaps

    Updated previously reply.
     
    StealWonders likes this.
  11. I have gotten this to work now with the help of a buddy.

    Code:
        public static int onlinePlayers = 0;
    Code:
                //Online-Players
                if(onlinePlayers != Bukkit.getOnlinePlayers().size()) {
                    obj.getScoreboard().resetScores("§7Online: §f§l" + onlinePlayers);
                }
                obj.getScore("§7Online: §f§l" + Bukkit.getOnlinePlayers().size()).setScore(40);
                onlinePlayers = Bukkit.getOnlinePlayers().size();
    And I managed to use the HashMap like you told me to with the class the player is playing :)
     
    Flaps likes this.
Thread Status:
Not open for further replies.

Share This Page