Scoreboard refreshing

Discussion in 'Spigot Plugin Development' started by Roimeiqui7, Aug 11, 2018 at 12:36 AM.

  1. Hello guys, I'm refreshing my scoreboard but it makes this strange thing: https://gyazo.com/65c9209e8d0eaf5200e7c90faf554117

    I don't know why is doing this because in my localhost works fine.

    EDIT: This is my scoreboard code:
    Code (Text):
    public static void setScoreboard(Player p) {
            FullPvP pl = FullPvP.getPlugin(FullPvP.class);
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(pl, new Runnable() {
                public void run() {
                    final Scoreboard board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
                    final Objective o = board.registerNewObjective("Scoreboard", "dummy");
                    o.setDisplayName(Placeholders.replaceValues(p, "&6&lZalexMC &7| &fFullPvP"));
                    o.setDisplaySlot(DisplaySlot.SIDEBAR);
                    final List<String> text = new ArrayList<String>();
                    text.add("&7-+--------------------+-");
                    text.add("&6Online» &f%online%");
                    text.add("&6Kills» &f%kills%");
                    text.add("&6Deaths» &f%deaths%");
                    if (Cooldown.isCooling(p.getName(), "Enderpearl")) {
                        text.add("&6EnderPearl» &f%time%");
                    }
                    if (ClanManager.isInClan(p)) {
                        text.add("&6Clan» &f" + ClanManager.getClan(p));
                    }
                    if (StaffCMD.a.contains(p)) {
                        text.add("&7-+--------------------+-");
                        text.add("&6StaffMode» &aEnabled");
                        text.add("   &eGamemode: &f" + p.getGameMode());
                        text.add("   &eStaffChat: &f"
                                + new me.roimeiqui.zfullpvp.commands.messages.iPlayer(p).isStaffChat());
                        text.add("   &eVanished: &f" + VanishCommand.isV.contains(p));
                    }
                    text.add("&7-+--------------------+-");

                    int size = text.size();
                    String f = "";
                    for (final String s : text) {
                        f = Placeholders.replaceValues(p, s);
                        int currentLine = size - 1;
                        if (currentLine <= 15 && currentLine-- > 0) {
                            f = String.valueOf(f) + Placeholders.colorcodes[currentLine--];
                        }
                        int deaths = getDeaths(p.getUniqueId());
                        int kills = getKills(p.getUniqueId());
                        o.getScore(ChatColor.translateAlternateColorCodes('&',
                                f.replace("%deaths%", String.valueOf(deaths)).replace("%kills%", String.valueOf(kills))
                                        .replace("%online%", String.valueOf(Bukkit.getServer().getOnlinePlayers().size()))
                                        .replace("%time%",
                                                String.valueOf(Cooldown.getRemaining(p.getName(), "Enderpearl")))))
                                .setScore(--size);
                    }
                    p.setScoreboard(board);
                }
            }, 0L, 1L);
        }
    Thanks for help
     
  2. It's probably because you're using Objectives instead of Teams. And it could also be the problem that you are refreshing the scoreboard EVERY tick. That could be too fast, so i suggest you to change it to 20 ticks
     
  3. I cannot change it to 20 ticks because of I have a enderpearl cooldown witch have decimals. If I change it to Teams it would be fine?
     
  4. Changing it to teams will help a lot
     
    • Agree Agree x 1

Share This Page