Skip to main content

How To Use?

The following example demonstrates how to use the Scoreboard system provided by the framework.

Player player = (Player) sender; // Retrieve the player instance

// Create a scoreboard for the player with the title "test"
Scoreboard scoreboard = BasePlugin.createScoreboard(player, "test");

// Set the title of the scoreboard (you can change it at any time)
scoreboard.setTitle("Un test");

// Make the scoreboard expire automatically after 5 seconds
scoreboard.expire(5, TimeUnit.SECONDS);

// Set lines for the scoreboard
scoreboard.setLine(0, "An Example"); // Line 0
scoreboard.setLine(1, "Another Line"); // Line 1

// Use the update method to dynamically update the scoreboard
scoreboard.update(20, mscoreboard -> {
// This will be executed every 20 ticks (1 second)
mscoreboard.setLine(0, "Test " + mscoreboard.getPlayer().getName());
// Line 0 will display "Test player_name"
});

// Show the scoreboard to the player
scoreboard.show();

Example Output When executed, the scoreboard will look something like this (in Minecraft):

  ----------------------
| Un test |
----------------------
| An Example | (Initially)
| Another Line |
----------------------

After 1 second:
----------------------
| Un test |
----------------------
| Test PlayerName | (Dynamic Update)
| Another Line |
----------------------

After 5 seconds:
(The scoreboard disappears automatically)

That's all