Scorebord won't show on join.

Discussion in 'Spigot Plugin Development' started by eatxaxcookie, May 30, 2015.

  1. hi
    i use this code for my scoreboard:
    Code (Text):
    void ScoreBoard () {
                ScoreboardManager manager = Bukkit.getScoreboardManager();
                Scoreboard board = manager.getNewScoreboard();
                Objective objective = board.registerNewObjective("test", "dummy");
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                objective.setDisplayName("§a§llevel §b§lplayer §c§lStreak");
                for(Player allPlayers : Bukkit.getOnlinePlayers()) {
                    (objective.getScore("§a§l" + (cfg.getInt("stats."+allPlayers.getUniqueId()+".level" )) + " §b" + allPlayers.getName())).setScore(cfg.getInt("stats."+allPlayers.getUniqueId()+".killstreak" ));
                    allPlayers.setScoreboard(board);              
                }
            }
    It does work i use it in PlayerDeathEvent but when i try to use it on the join/quit event it doesn't show for the person that joined or update for the others.

    Code (Text):
            @EventHandler
            public void onQuit(PlayerQuitEvent event){
                ScoreBoard();
                }
     
  2. Have you try adding a delay? o_O
     
    • Like Like x 1
  3. Sending spawn entity packets, UI updates, etc, just won't work until the client can see chunks. When PlayerJoinEvent is called, the user is still download the terrain.
     
  4. Maybe healthbar or some other plugin isn't set to compatibility mode. Some other things interfere with the sidebar. Show us your other plugins
     
  5. Try to do it with Player p then
    Code (Text):
    public void onquit(PlayerQuitEvent e){
    ScoreBoard();
    e.getPlayer.setScoreboard(manager)
    }
     

    Also your code is on Quit you must do it with On PlayerJoinEvent :)
     
  6. adding delay worked THX! :D
     
  7. public void onPlayerJoin(PlayerJoinEvent e) {
    Player p = e.getPlayer();
    p.setScoreboard(nameofthescoreboard);