Tablist glitching, Scoreboard issue??

Discussion in 'BungeeCord Plugin Development' started by Timuh, Jul 11, 2015.

  1. Well when i press tab its all buggy and glitchy. How can i fix

    Here is the code
    Code (Text):
    @EventHandler(priority=EventPriority.HIGHEST)
        public void scoreboard(PlayerJoinEvent e) {
            final Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
           
            Objective objective = sb.registerNewObjective("showhealth", "health");
            objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
            objective.setDisplayName(ChatColor.RED + "❤");
           
            for(Player online : Bukkit.getOnlinePlayers()) {
                online.setScoreboard(sb);
                online.setHealth(online.getHealth());
            }
           
            sb.registerNewTeam("member");
            sb.registerNewTeam("vip");
            sb.registerNewTeam("buildteam");
            sb.registerNewTeam("helper");
            sb.registerNewTeam("mod");
            sb.registerNewTeam("admin");
            sb.registerNewTeam("owner");
           
            final Team member = sb.getTeam("member");
            final Team vip = sb.getTeam("vip");
            final Team buildteam = sb.getTeam("buildteam");
            final Team helper = sb.getTeam("helper");
            final Team mod = sb.getTeam("mod");
            final Team admin = sb.getTeam("admin");
            final Team owner = sb.getTeam("owner");
           
            member.setPrefix(ChatColor.GRAY + "[" + ChatColor.YELLOW + "D" + ChatColor.GRAY + "] ");
            vip.setPrefix(ChatColor.AQUA + "[VIP] ");
            buildteam.setPrefix(ChatColor.DARK_AQUA + "[BUILDTEAM] ");
            helper.setPrefix(ChatColor.GREEN + "[HELPER] ");
            mod.setPrefix(ChatColor.GOLD + "[MOD] ");
            admin.setPrefix(ChatColor.RED + "[ADMIN] ");
            owner.setPrefix(ChatColor.RED + "[OWNER] ");
           
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    for (Player player : Bukkit.getOnlinePlayers()) {
                        player.setScoreboard(sb);
                        if (player.hasPermission("member.rank")) {
                            member.addPlayer(player);
                           
                             vip.removePlayer(player);
                             buildteam.removePlayer(player);
                             helper.removePlayer(player);
                             mod.removePlayer(player);
                             admin.removePlayer(player);
                        }
                        if (player.hasPermission("vip.rank")) {
                             vip.addPlayer(player);
                           
                             member.removePlayer(player);
                             buildteam.removePlayer(player);
                             helper.removePlayer(player);
                             mod.removePlayer(player);
                             admin.removePlayer(player);
                         }
                         if (player.hasPermission("buildteam.rank")) {
                             buildteam.addPlayer(player);
                           
                             member.removePlayer(player);
                             vip.removePlayer(player);
                             helper.removePlayer(player);
                             mod.removePlayer(player);
                             admin.removePlayer(player);
                         }
                         if (player.hasPermission("helper.rank")) {
                             helper.addPlayer(player);
                           
                             member.removePlayer(player);
                             vip.removePlayer(player);
                             buildteam.removePlayer(player);
                             mod.removePlayer(player);
                             admin.removePlayer(player);
                         }
                         if (player.hasPermission("mod.rank")) {
                             mod.addPlayer(player);
                           
                             member.removePlayer(player);
                             vip.removePlayer(player);
                             buildteam.removePlayer(player);
                             helper.removePlayer(player);
                             admin.removePlayer(player);
                         }    
                         if (player.hasPermission("admin.rank")) {
                             admin.addPlayer(player);
                           
                             member.removePlayer(player);
                             vip.removePlayer(player);
                             buildteam.removePlayer(player);
                             helper.removePlayer(player);
                             mod.removePlayer(player);
                         }
                         if (player.hasPermission("owner.rank")) {
                             owner.addPlayer(player);
                           
                             member.removePlayer(player);
                             vip.removePlayer(player);
                             buildteam.removePlayer(player);
                             helper.removePlayer(player);
                             mod.removePlayer(player);
                             admin.removePlayer(player);
                         }
                    }
                }
            }
            , 60L, 60L);
        }
     
  2. What do you mean it is all buggy and glitchy? What happens? Do you get an error?
     
  3. no it flickers a lot, do i have the timing wrong ?
     
  4. Probably because you are setting a new scoreboard every time? Just get the player's current scoreboard and modify it.
     
  5. how would i do that? I got this from the tut and I'm all new the java
     
  6. Well I don't want to write all the code for you but something along the lines of
    Code (Text):
    player.getScoreboard().getObjective(DisplaySlot.BELOW_NAME)
    //then modify this scoreboard objective rather than setting a new scoreboard
     
  7. i
    im so lost
     
  8. maybe you need a torch to find out how to use java.
     
  9. You can't create a new scoreboard for each update, you need to get the current player scoreboard, take it and update.