HELP Scoreboard

Discussion in 'Spigot Plugin Development' started by TheSkillex12, Apr 19, 2017.

  1. Hello people!
    I would like to know if you could help me do the following
    I want to do a Scoreboard AntiFlicker with Variables
    Example:
    Scoreboard:
    Title: 'title example'
    Lines:
    - '&e '
    - '&fName: %player%'
    - '&fKills: %kills%'
    - '&fDeaths: %death%'
    - '&2 '
    - '&fPlaying: %playing%'
    - '&f '
    - '&cmc.myserver.com'

    But something I want you to understand is that the lines will not be in this order
    This is just an example
     
  2. Eh ok, and now what don't you understand with scoreboards?
    What have you tried so far?
     
  3. Code (Text):

    public void setScoreboard(Player player) {
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Objective objective = board.registerNewObjective("Scoreboard", "dummy");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            int scoretoset = iz.getConfig().getStringList("scoreboard.lines").size();
            for (String string : iz.getConfig().getStringList("scoreboard.lines")) {
                string = string.replaceAll("%playing%", player.getName());
                string = string.replaceAll("%kills%", player.getWorld().getName());
                string = string.replaceAll("%deaths%", Bukkit.getOnlinePlayers().size() + "");
                string = string.replaceAll("&", "§");
                final Score score = objective.getScore(Bukkit.getOfflinePlayer(string));
                score.setScore(scoretoset);
                --scoretoset;
            }
            String scorename = iz.getConfig().getString("scoreboard.name");
            scorename = scorename.replaceAll("&", "§");
            objective.setDisplayName(scorename);
            player.setScoreboard(board);
        }
     
     
  4. But I want it to be antiFlicker
     
  5. So the case is you are generating a new scoreboard each time. What you want to do is look at teams in the scoreboard package. Name it whatever and have the variable placeholders as a suffix and change as necessary.
     
  6. I'm half new to this
    Some example code?
     
  7. This has been referenced a few times:
    https://gist.github.com/mkotb/d99eccdcc78a43ffb707

    Or an excerpt from something I was doing:
    Code (Text):

    Team time = scoreboard.registerNewTeam("time");
    time.addEntry(ChatColor.YELLOW.toString()); //Entry can be anything really
    time.setPrefix(ChatColor.DARK_GREEN + "Time: ");
    time.setSuffix(ChatColor.YELLOW + secondsToString(timeLeft)); //This is a utility method from elsewhere
    o.getScore(ChatColor.YELLOW.toString()).setScore(2); //Set position in objective

    //To change value
    scoreboard.getTeam("time").setSuffix(ChatColor.YELLOW + secondsToString(timeLeft));