Scoreboard keeps flashing

Discussion in 'Plugin Development' started by maux, Jul 30, 2017.

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

    maux

    Hey guys my scoreboard keeps flashing. I feel like it might by the kind of task I'm using? I'm not entirely sure. What should I check on?

    Code:
    @Override
        public void onEnable() {
           
            PluginManager a = Bukkit.getPluginManager();
           
            a.registerEvents(new PlayerJoin(), this);
            a.registerEvents(new PlayerQuit(), this);
            a.registerEvents(new ServerMOTD(), this);
           
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    sendScoreboard();
                    sendTablist();
                }
            }, 0, 20);
           
        }
     
  2. Offline

    Machine Maker

    @maux
    1. I'm not sure if that is the issue, but you should use BukkitRunnables instead of BukkitScheduler. Read this post.
     
  3. Offline

    timtower Administrator Administrator Moderator

    @X1machinemaker1X Should not be.

    @maux Your sendScoreboard method is probably making a new scoreboard every time it runs. Re-use the old one instead.
     
  4. Offline

    maux

    @timtower by reusing the old scoreboard, you mean just having the score change not the entire board?

    EDIT:

    NaturalPvP.onEnable() function (open)

    Code:
    @Override
        public void onEnable() {
           
            PluginManager a = Bukkit.getPluginManager();
           
            a.registerEvents(new PlayerJoin(), this);
            a.registerEvents(new PlayerQuit(), this);
            a.registerEvents(new ServerMOTD(), this);
           
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    sendScoreboard();
                    sendTablist();
                }
            }, 0, 20);
           
        }


    NaturalPvP.sendScoreboard() function (open)
    Code:
    public static void sendScoreboard() {
            for (Player player : Bukkit.getOnlinePlayers()) {
                NaturalScoreboard scoreboard = new NaturalScoreboard();
                MauxScoreboard board = new MauxScoreboard("§a§l" + NaturalPvP.getServerName());
                scoreboard.sendScoreboard(player, board);
                board.build();
                board.send(player);
            }
        }


    NaturalScoreboard.sendScoreboard() function (open)

    Code:
    public void sendScoreboard(Player player, MauxScoreboard scoreboard) {
    
                 
    
            Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
    
            User b = ess.getUser(player);
    
            FPlayer c = FPlayers.getInstance().getByPlayer(player);
    
            scoreboard.add("§8§l§m================");
    
            scoreboard.add("§f§lPlayer");
    
            scoreboard.add("§7Name: §a" + player.getName());
    
            scoreboard.add("§7Balance: §a" + b.getMoney());
    
            scoreboard.blankLine();
    
            scoreboard.add("§f§lFaction");
    
            if (!c.hasFaction()) {
    
                scoreboard.add("§7Faction: §cWilderness");
    
                scoreboard.add("§7Power: §c" + c.getFaction().getPowerRounded() + "§8/§c" + c.getFaction().getPowerMax());
    
            } else {
    
                scoreboard.add("§7Faction: §e" + c.getFaction().getTag());
    
                scoreboard.add("§7Power: §b" + c.getFaction().getPowerRounded() + "§8/§b" + c.getFaction().getPowerMax());
    
            }
    
            scoreboard.blankLine();
    
            scoreboard.add("§f§lServer");
    
            scoreboard.add("§7Online: §a" + Bukkit.getOnlinePlayers().size());
    
            scoreboard.add("§8§l§m================");
    
            scoreboard.add("§9§l" + NaturalPvP.getServerAddress());
    
         
    
        }
     
  5. Offline

    timtower Administrator Administrator Moderator

  6. Offline

    maux

    @timtower I changed the function, and nothing showed up!

    Code:
    public void sendScoreboard(Player player, MauxScoreboard scoreboard) {
                   
            Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
            User b = ess.getUser(player);
            FPlayer c = FPlayers.getInstance().getByPlayer(player);
           
            scoreboard.add("§8§l§m================");
            scoreboard.add("§f§lPlayer");
            scoreboard.add("§7Name: §a" + player.getName());
           
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(NaturalPvP.getNaturalPvP(), new Runnable() {
                public void run() {
                   
                    scoreboard.add("§7Balance: §a" + b.getMoney());
                    scoreboard.blankLine();
                    scoreboard.add("§f§lFaction");
                    if (!c.hasFaction()) {
                        scoreboard.add("§7Faction: §cWilderness");
                        scoreboard.add("§7Power: §c" + c.getFaction().getPowerRounded() + "§8/§c" + c.getFaction().getPowerMax());
                    } else {
                        scoreboard.add("§7Faction: §e" + c.getFaction().getTag());
                        scoreboard.add("§7Power: §b" + c.getFaction().getPowerRounded() + "§8/§b" + c.getFaction().getPowerMax());
                    }
                    scoreboard.blankLine();
                    scoreboard.add("§f§lServer");
                    scoreboard.add("§7Online: §a" + Bukkit.getOnlinePlayers().size());
                   
                }
            }, 0, 20);
           
            scoreboard.add("§8§l§m================");
            scoreboard.add("§9§l" + NaturalPvP.getServerAddress());
           
        }
     
  7. Offline

    timtower Administrator Administrator Moderator

    @maux You do still need to send it.
     
  8. Offline

    maux

  9. Offline

    timtower Administrator Administrator Moderator

    @maux Do you send it every time it updates?
     
  10. Offline

    maux

    @timtower the only thing that gets updated is the scores having to do with faction, balance, and amount of player. It gets sent to the player on the onEnable() function
     
  11. Offline

    timtower Administrator Administrator Moderator

    @maux You need to keep sending it, otherwise the player won't receive the updates.
     
  12. Offline

    AdamDev

    @maux do any other plugins use a scoreboard? That might be what's causing it to blink.
    Another thing that may be why it's not showing up is that your only allowing the name and player name display. Try setting the score of the text you want.
     
Thread Status:
Not open for further replies.

Share This Page