Solved Scoreboard doenst appear

Discussion in 'Spigot Plugin Development' started by HockeyFreak062, Feb 12, 2020.

  1. Hey I'm trying to make a scoreboard for my plugin for 1.13. But it doesn't appear in game when you join the server. There is no error in the console so I can't really figure out what's wrong. And yes the class is registered This is my code:
    Code (Java):

    public class Scoreboard implements Listener {

        @EventHandler
        public void onJoin(PlayerJoinEvent event) {

            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Objective objective = manager.getNewScoreboard().registerNewObjective("test", "Test", "dummy");

            Player p = event.getPlayer();

            objective.setDisplayName(Gijs.cc("&a&lScoreboard"));
            Score score = objective.getScore("&aTest");
            score.setScore(10);

            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            p.setScoreboard(manager.getNewScoreboard());
        }
    }
     
  2. You show the player a different scoreboard, each time you use #getNewScoreboard it returns a NEW scoreboard.
     
  3. So i should use #getMainScoreboard instead?
     
  4. You do not have to as long as you give the player instance of the scoreboard that you modified
     
  5. I don't really use scoreboards and could not find any 1.13 tutorials. Could you help me with how to fix it bacause is dont understand
     
  6. Code (Java):
    Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
    // Modifications
    p.setScoreboard(board);
     
  7. It says i should use this code but then it doesn't work. There is still no error.
    Code (Java):
     
    public class Scoreboard implements Listener {

        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Objective objective = manager.getNewScoreboard().registerNewObjective("test", "Test", "dummy");
        Scoreboard board = (Scoreboard) Bukkit.getScoreboardManager().getNewScoreboard();

        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            Player p = event.getPlayer();

            objective.setDisplayName(Gijs.cc("&a&lScoreboard"));
            Score score = objective.getScore("&aTest");
            score.setScore(10);

            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            p.setScoreboard((org.bukkit.scoreboard.Scoreboard) board);
        }
    }
     
  8. Once again, you create 2 different scoreboards..
     
  9. Code (Text):
    manager.getNewScoreboard()
    you're creating a new board here
    Code (Text):
    Bukkit.getScoreboardManager().getNewScoreboard()
    and here. so you have 2 instances of a scoreboard. 1 with objectives, 1 without. youre giving the players one without.
     
  10. Thanks! I changed it and this worked :)