Scoreboard Flashing problem

Discussion in 'Plugin Development' started by defineci00, Oct 21, 2014.

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

    defineci00

    My scoreboard flashing after using the my update scoreboard function.
    How can I fix it ?

    Scoreboard update function;

    Code:java
    1.  
    2. public static void UpdateScoreboard(){
    3. removeOldScore("§eHaraçlar: §r");
    4. Main.instance.durum.getScore("§eHaraçlar: §r" + Main.instance.yasiyor.size()).setScore(2);
    5. updatePlayers();
    6. }
    7.  
    8. static void updatePlayers(){
    9. for (Player oyuncular : Bukkit.getOnlinePlayers()){
    10. oyuncular.setScoreboard(Main.instance.durumboard);
    11. }
    12. }
    13.  
    14. static void removeOldScore(String score){
    15. for(OfflinePlayer player : Main.instance.durumboard.getPlayers()){
    16. if(player.getName().startsWith(score)){
    17. Main.instance.durumboard.resetScores(player);
    18. break;
    19. }
    20. }
    21. }
     
  2. Offline

    TheCodingCat

    Its because you are removing a score, then re adding it. You can sort of see. Instead of removing and adding how about you try replacing instead :).
     
  3. Offline

    defineci00


    How can I replace ? What is replace method ?
    Sorry for bad English and thanks for suggestion :rolleyes:
     
  4. Offline

    TheCodingCat

    so can you send me an image of your scoreboard(just so I know exactly how you are using it :p)
     
  5. Offline

    Konato_K

    If you're never removing the scoreboard from the players then you don't need to use updatePlayers();

    Using Player.setScoreboard(Scoreboard) makes the server send packets to the client to remove their scoreboard and then set a new one, this makes the scoreboard flash.
     
  6. Offline

    defineci00


    here;

    [​IMG]

    up

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  7. Offline

    fireblast709

    defineci00 register a new objective, set all the new scores, then set the display slot (thus swapping the two objectives), and unregister the old objective.
     
  8. Offline

    BloodBacker


    How... i tried it already but it doesn't work...
     
  9. Offline

    defineci00


    Yeah me too
     
  10. Offline

    fireblast709

    BloodBacker defineci00 "Doesn't work" is a bit too vague. What exactly doesn't work? Also post the code you tried.
     
  11. Offline

    defineci00

    it removes itself when 2 people join the server, any ideas why?
     
  12. Offline

    fireblast709

  13. Offline

    defineci00

    Register Scoreboard function (with register arena)


    Code:java
    1. public Arena(int no, String mapName){
    2. this.map= mapName;
    3. this.arenaNo = no;
    4.  
    5. ScoreboardManager scoreboardd = Bukkit.getScoreboardManager();
    6. scoreboard = scoreboardd.getNewScoreboard();
    7.  
    8. objective = scoreboard.registerNewObjective("kills"+arenaNo, "dummy");
    9.  
    10. Red = scoreboard.registerNewTeam("Red");
    11. Blue = scoreboard.registerNewTeam("Blue");
    12. Green = scoreboard.registerNewTeam("Green");
    13. Yellow = scoreboard.registerNewTeam("Yellow");
    14.  
    15. Red.setPrefix("§c");
    16. Blue.setPrefix("§b");
    17. Green.setPrefix("§a");
    18. Yellow.setPrefix("§e");
    19.  
    20. Red.setAllowFriendlyFire(false);
    21. Blue.setAllowFriendlyFire(false);
    22. Green.setAllowFriendlyFire(false);
    23. Yellow.setAllowFriendlyFire(false);
    24.  
    25. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    26.  
    27. objective.setDisplayName("§aServer: §c" + Main.instance.getConfig().getString("ServerNo") + "-" + arenaNo);
    28. objective.getScore("§6§l" + "▶" + "Game Score").setScore(10);
    29. objective.getScore("§cRed: §r").setScore(RedTeam.size());
    30. objective.getScore("§bBlue: §r").setScore(BlueTeam.size());
    31. objective.getScore("§aGreen: §r").setScore(GreenTeam.size());
    32. objective.getScore("§eYellow: §r").setScore(YellowTeam.size());
    33. }


    Set scoreboard
    Code:java
    1. @EventHandler
    2. public void joinp(PlayerJoinEvent event){
    3. event.getPlayer().setScoreboard(scoreboard);
    4. }
     
  14. Offline

    fireblast709

    defineci00 well setting a Player's scoreboard shouldn't cause another one's to disappear. Is there anything else you do when a player joins?
     
  15. Offline

    defineci00

    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page