Update scoreboard

Discussion in 'Spigot Plugin Development' started by LagBug, Jun 1, 2018.

  1. Hey there, I'm trying to update a scoreboard with teams using this:
    Code (Java):
        public void updateScoreboard(Player player) {
            Scoreboard board = player.getScoreboard();

                for (Object text : main.getConfig().getList("scoreboard.rows")) {

                    Team team = board.getTeam(firstHalf(text, player));  

                    team.setPrefix(lines(text, player).substring(0, lines(text, player).length() / 2));
                    team.setSuffix(lines(text, player).substring(lines(text, player).length() / 2));
    but it doesn't seem to work. It also doesn't give any error, it just doesn't update any idea why?
  2. So, can you post all the code and a config copy?

    (Code with pastebin pls)
  3. Not sure if this will effect it, but it should be for(String text : main.getConfig().getStringList(“scoreboard.rows”))
  4. I know I can do it with that way as well, but as you said that won't affect/fix it, thanks tho
  5. Anyone else can help me?
  6. You should post all your functions (firstHalf and lines).
  7. firstHalf:
    Code (Java):
        public String firstHalf(Object text, Player p) {
            Placeholder pl = new Placeholder();
            return pl.hold(text.toString().substring(0, text.toString().length() / 2));
    Code (Java):
        public String secondHalf(Object text, Player p) {
            Placeholder pl = new Placeholder();
            return pl.hold(text.toString().substring(text.toString().length() / 2));
    Code (Java):
        public String lines(Object text, Player p) {
            Placeholder pl = new Placeholder();
            double gold = main.getDataFile().getDouble("pdata." + p.getUniqueId().toString() + ".gold");
            String end = firstHalf(text, p) + secondHalf(text, p);
            return pl.hold(end.replace("%lvl%", Integer.toString(p.getLevel()))
                    .replace("%xp%", Integer.toString(p.getExpToLevel()))
                    .replace("%gold%", Double.toString(gold))
                    .replace("%status%", pl.hold(status(p))));
    #10 LagBug, Jun 2, 2018
    Last edited: Jun 2, 2018