Scoreboard (Not API)

Aug 27, 2016
Scoreboard (Not API)
  • BungeeCord Scoreboard (Not API)

    How to use BungeeCord to create a scoreboard



    @md_5 & @Thinkofdeath created the Bungeecord Scoreboard API (net.md_5.bungee.api.score.*) a long time ago. But it isn't ready to use yet. Nevertheless they already made the packets. So we can use them to create scoreboards! In the following code examples p stands for some ProxiedPlayer.


    How works a scoreboard?(top)

    Very important for creating a scoreboard via Bungeecord is to understand who scoreboards work. The best way to figureout is here.

    Creating an objective(top)

    So now we know how scoreboards work. First we have to create an objective.
    Code (Text):
    ScoreboardObjective objective = new ScoreboardObjective("test", "Test", "integer", (byte) 0);
    p.unsafe().sendPacket(objective);
    Explanation:
    "test" is an unique name for the scoreboard
    "Test" is the name which should be displayed
    "integer" this could be replaced to "hearts" - more infos
    0 - 0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.

    Creating and removing a score(top)

    Code (Text):
    ScoreboardScore score = new ScoreboardScore("Hallo", (byte) 0, "test", 0);
    p.unsafe().sendPacket(score);
    Explanation:
    "Hallo" is the name of the score to be updated or removed
    0 - 0 to create/update an item. 1 to remove an item.
    "test" is the name of the objective the score belongs to
    0 - The score to be displayed next to the entry.

    Displaying the scoreboard(top)

    Now the client knows all about the scorebaord, but we have to tell the client to display the scoreboard.
    Code (Text):
    ScoreboardDisplay display = new ScoreboardDisplay((byte) 1, "test");
    p.unsafe().sendPacket(display);
    Explanation:
    1 - The position of the scoreboard. 0: list, 1: sidebar, 2: below name.
    "test" - The unique name for the scoreboard to be displayed.

    And that's it. It is obviously very simple. And if you did everything right it should look like this:
    [​IMG]
  • Loading...
  • Loading...