Getting Started
How to set-up the PowerRanks API

Get an API instance in Java

To get access to the API use the following lines:
1
import nl.svenar.PowerRanks.PowerRanks;
2
import nl.svenar.PowerRanks.api.PowerRanksAPI;
3
4
PowerRanksAPI api = PowerRanks.loadAPI();
Copied!
This creates a variable api that can be used to control features in PowerRanks. Continue to API functions to know what can be done with the PowerRanks API.

Examples

The examples below use the api variable as described above.

Create a new rank

1
String rankName = "myAwesomeRank";
2
3
boolean success = api.createRank(rankName);
4
if (success) {
5
System.out.println("The rank has been created!");
6
} else {
7
System.out.println("Failed to create rank!");
8
}
Copied!

Add a rank to a player

1
String rankName = "myAwesomeRank";
2
String playerName = "svenar";
3
4
// Just for this example
5
Player player = null;
6
for (Player onlinePlayer : Bukkit.getServer().getOnlinePlayers()) {
7
if (onlinePlayer.getName().equals(playerName)) {
8
player = onlinePlayer;
9
break;
10
}
11
}
12
13
if (player != null) {
14
boolean success = api.addPlayerRank(player, rankName);
15
if (success) {
16
System.out.println("The rank has been granted to " + player.getName());
17
} else {
18
System.out.println("Failed to give the rank '" + rankName + "' to " + player.getName());
19
}
20
} else {
21
System.out.println("Player is offline");
22
}
Copied!
Last modified 20d ago