-
-
Notifications
You must be signed in to change notification settings - Fork 4
Developer API
- Create custom placeholders
- Create custom scoreboards or update existing ones
- Set a custom prefix/suffix (coming soon)
- Set a custom tablist (planned)
Don't forget to put "PowerBoard" as depend or softdepend.
CustomPlaceholders ph = new CustomPlaceholders() {
@Override
public String replace(Player p, String s) {
if(s.contains("%my_placeholder%")) { // Check if placeholder is in string to prevent unnecessary code executions
// In here you can put any code that is necessary for the replacement
s = s.replace("%my_placeholder%", "It works!"); // Replace the placeholder
}
// Here you can add as many placeholders as you like
return s; // Return the string with replaced placeholders
}
};
PowerBoardAPI.registerCustomPlaceholders(ph);
Set the boolean to false if you want to use a PowerBoard scoreboard (a scoreboard that is configured in the PB config). This can be useful if you don't want that everyone gets a scoreboard when he joins. But for this you also have to disable the scoreboard in PB's config.yml. If it is disabled in the config.yml no player gets a scoreboard clearly. But you can then use this API to give a specific player a scoreboard which is configured in PB.
If you want a completely custom scoreboard (which is only set and changed trough the API), set it to true. Then the scoreboards from PB won't be applied. You have to set it yourself with the setTitle and setScore methods.
PowerBoardAPI.setScoreboard(p, true/false);
PowerBoardAPI.removeScoreboard(p);
Set the boolean to true if you have placeholders in the string.
This can also be used to update a line. Works with scoreboards from PB itself too (the ones that are configured in PB's folder).
// Change the text of the score with the ID (red number) 2 to "Hello World"
PowerBoardAPI.setScoreboardScore(p, "Hello World", 2, false);
You can also set all scores at once, which I recommend if you want to set a custom scoreboard.
Better use the above method (a single line) only if you want to update a line, set a custom score value (the red number) or if it is better in your use-case.
Set the boolean to true if you have placeholders from PAPI or PB in the string.
ArrayList<String> scores = new ArrayList<>();
scores.add("Score 1");
scores.add("Score 2");
scores.add("Score 3");
PowerBoardAPI.setScoreboardScores(p, scores, false);
Coming soon
Planned, can take a while