Bugged scoreboard @ onEnable?

Discussion in 'Plugin Development' started by jusjus112, Oct 20, 2014.

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

    jusjus112

    hey,

    i have a made a plugin, that gives colors above players his name.
    i have made it in my onenable, but when i will test it it works
    but only 1 name is bugged, it turns white and color of the rank and again white and the color.
    Every time he/she is online, it flashes to white and his color.

    Here is my code in my onenable:
    Code:java
    1. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    2. @Override
    3. public void run() {
    4. for (final Player all : Bukkit.getServer().getOnlinePlayers()) {
    5. if (all.hasPermission("network.rank.owner")) {
    6. owner.addPlayer(Bukkit.getOfflinePlayer(all.getName()));
    7. owner.setPrefix(ChatColor.GOLD + "");
    8. }else if (all.hasPermission("network.rank.builder")) {
    9. builder.addPlayer(Bukkit.getOfflinePlayer(all.getName()));
    10. builder.setPrefix(ChatColor.GREEN + "");
    11. }else if (all.hasPermission("network.rank.vip")) {
    12. vip.addPlayer(Bukkit.getOfflinePlayer(all.getName()));
    13. vip.setPrefix(ChatColor.YELLOW + "");
    14. }else if (all.hasPermission("network.rank.vipPlus")) {
    15. vipPlus.addPlayer(Bukkit.getOfflinePlayer(all.getName()));
    16. vipPlus.setPrefix(ChatColor.LIGHT_PURPLE + "");
    17. }else if (all.hasPermission("network.rank.legend")) {
    18. legend.addPlayer(Bukkit.getOfflinePlayer(all.getName()));
    19. legend.setPrefix(ChatColor.DARK_AQUA + "");
    20. }else {
    21. players.addPlayer(Bukkit.getOfflinePlayer(all.getName()));
    22. players.setPrefix(ChatColor.GRAY + "");
    23. }
    24. all.setScoreboard(sBoard);
    25. }
    26.  
    27. }
    28. }, 20, 20);

    EDIT: I think it happens when i reload the server, and there are no players online, the plugin shuts down and nothing happens. But when there is 1 player online, and i do /reload then it bugs and will the plugin working
     
  2. Offline

    Unica

    You have a repeating task :confused:.

    Maybe,
    Code:java
    1. private String getNameTag(Team curRank){
    2. switch(curRank){
    3. case legend:
    4. return ChatColor.SOMETHING + "";
    5. break;
    6. }
    7. }

    ?
     
  3. Offline

    jusjus112

    Unica
    But i have, when the player switches rank or join the server, it updates!
     
  4. Offline

    Unica

    jusjus112

    Why you have a repeating task then?
     
    VG.Developments likes this.
  5. Offline

    jusjus112

    Unica
    Because, it updates every second!
     
  6. Offline

    Unica

    jusjus112

    Why do you need to update every second?
    Just update it when a player joins, on a reload, and one a player get's demote / promoted.

    This causes lagg and possible causes the bug.
     
  7. Offline

    jusjus112

    Unica
    hmmm, i think thats what i gone do. Thanks anyways :D
     
Thread Status:
Not open for further replies.

Share This Page