-
-
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.
Warning: This API won't work as described with the current and latest version! Please wait until is v3.5.11 is released since there were a few changes again!
CustomPlaceholders ph = new CustomPlaceholders() {
@Override
public @NotNull 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.
If you have set the boolean to true, set the scoreboardName to null.
If you have set the boolean to false and want to use the PB config as normal with conditions and etc., set the scoreboardName to null.
If you have set the boolean to false but want to set a specific scoreboard (configured in PB), set scoreboardName to the name of the scoreboard (without .yml)
PowerBoardAPI.setScoreboard(p, true/false, scoreboardName);
PowerBoardAPI.removeScoreboard(p);
Set the boolean to true if you have placeholders in the string.
Works with scoreboards from PB itself too (the ones that are configured in PB's folder).
PowerBoardAPI.setScoreboardTitle(p, title, usePlaceholders) {
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);
It isn't fully integrated yet, but the listener is working.
You have to set the permission system in the config.yml to "API" to set custom Ranks. I'm currently not sure, but it should be possible to still use your permission system (for Example LuckPerms) and change for example the chat prefix with the #setChatPrefix() function.
Example for the listener:
@EventHandler
public void onRankEvent(TeamSetEvent e) {
Player p = e.getPlayer();
if(p.getName().equals("Xitecraft")) {
e.setChatPrefix("Xitee: "); // Chat -> "Xitee: Hello"
e.setNameColor(ChatColor.BLUE); // The color of the player's name in the tablist
e.setPrefix(ChatColor.RED+"[OWNER]");
e.setSuffix(ChatColor.AQUA+"[SUFFIX]");
e.setRankDisplayName("Owner's Displayname"); // This will be displayed if you use the placeholder %player_rank% somewhere.
e.setPlayerListName("HEY"); // <-- This is optional. If you set a player list name, you can have colored names in the tablist and no char limit.
e.setWeight(999); // The weight of the rank. This is used to sort the players in the tab. Higher number = higher place in tab
}
}
Planned, can take a while