Solved Scoreboard packets

Discussion in 'Spigot Plugin Development' started by Janderup, Jul 15, 2018.

  1. Hi, I'm currently using the Bukkit API for scoreboards but using that doesn't allow me to either create scoreboards for tab. So now I want to make scoreboards through packets. But when it tries to set my scoreboard, I get kicked from the server, the console then gives some errors:
    Code (Text):
    [12:03:21 INFO]: janderup[/] logged in with entity id 4972 at ([world]327.30913298875686, 81.0, 193.78928703855203)
    [12:03:28 ERROR]: java.lang.NullPointerException
    [12:03:28 ERROR]: java.lang.NullPointerException
    [12:03:28 WARN]: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
    java.nio.channels.ClosedChannelException: null
            at$AbstractUnsafe.write(...)(Unknown Source) ~[Spigot.jar:git-Spigot-3d850ec-809c399]
    [12:03:28 INFO]: janderup lost connection: Disconnected
    I am using the following code that the server runs every 10 seconds:

    Code (Java):
    public static void set(Player p) {
            Scoreboard board = new Scoreboard();
            ScoreboardObjective objective = board.registerObjective("Test", IScoreboardCriteria.b);
            board.setDisplaySlot(1, objective);
            new ScoreboardScore(board, objective, "Test").setScore(1);
            PacketPlayOutScoreboardObjective createPacket = new PacketPlayOutScoreboardObjective();
            PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(objective, 1);
            PacketPlayOutScoreboardDisplayObjective display = new PacketPlayOutScoreboardDisplayObjective();
            sendPacket(p, removePacket);
            sendPacket(p, createPacket);
            sendPacket(p, display);
            for (ScoreboardScore score : board.getScores()) {
                PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(score);
                sendPacket(p, scorePacket);
        public static void sendPacket(Player p, Packet packet) {
            ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
    Any help is appriciated ;)
    • Like Like x 1
  2. Do not use new Scoreboard() but this:
    Code (Java):
    Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
  3. It's not a bukkit scoreboard
  4. But yes it is a Bukkit scoreboard and nothing else. Because what did you think?

    The other solution is:
    Code (Java):
    Scoreboard board = p.getScoreboard();
  5. ScoreboardObjective is an import of nms so it's not a Bukkit scoreboard
    • Winner Winner x 1
  6. @TomDev there are 2 options with that code you sent: 1. I have totally no idea how to use it. 2. It just doesn't work.
    Sorry for this late response, totally forgot this thread.
  7. If you'r talking about this code
    Simply create a class then copy all the code.
    After that new ScoreboardSign(player, objectiveName)
    then setLine ect ...

    If you wan't to use packet read
  8. Thanks a lot, it works! ;)
  9. Just use protocollib & the respective wrappers for it, why make it so hard?