Skip to content

Scoreboard API

Faizaan edited this page Jan 3, 2017 · 1 revision

Prison-Core provides a neat little Scoreboard API that lets you create nice sidebars with ease. It's a very simple system. The best way to show it to you, in my opinion, is to provide you with an all-inclusive example. Behold!

// create a new scoreboard with title
Scoreboard scoreboard = new Scoreboard("&a&lScoreboard API:");
// text with custom score
scoreboard.add("&lCustom scores ->", 1234);

// also supports blank lines (up to 23 of them)
scoreboard.blankLine();
scoreboard.add("&cBLANK LINES");
scoreboard.blankLine();

// if you dont specify a score it will display them in the order you add them in
scoreboard.add("lines");
scoreboard.add("&bin");
scoreboard.add("&edescending");
scoreboard.add("&2order");
scoreboard.add(":)");
scoreboard.blankLine();

// the text can be up to 48 characters long (including color codes)
scoreboard.add("and long lines with up to &l48 characters");

// call this to create the scoreboard, must be called before use or the scoreboard won't work
scoreboard.build();

// send the scoreboard to the player(s), takes a single value or an array (varargs)
scoreboard.send(player);

It's very simple and flexible. Note that there is a basic implementation of a raw scoreboard API in the tech.mcprison.prison.platform.scoreboard package - though as of API 30, it's not yet complete.