Getting Started
How to set-up the PowerRanks API
To get access to the API use the following lines:
import nl.svenar.PowerRanks.PowerRanks;
import nl.svenar.PowerRanks.api.PowerRanksAPI;
PowerRanksAPI api = PowerRanks.loadAPI();
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.
The examples below use the api variable as described above.
String rankName = "myAwesomeRank";
boolean success = api.createRank(rankName);
if (success) {
System.out.println("The rank has been created!");
} else {
System.out.println("Failed to create rank!");
}
String rankName = "myAwesomeRank";
String playerName = "svenar";
// Just for this example
Player player = null;
for (Player onlinePlayer : Bukkit.getServer().getOnlinePlayers()) {
if (onlinePlayer.getName().equals(playerName)) {
player = onlinePlayer;
break;
}
}
if (player != null) {
boolean success = api.addPlayerRank(player, rankName);
if (success) {
System.out.println("The rank has been granted to " + player.getName());
} else {
System.out.println("Failed to give the rank '" + rankName + "' to " + player.getName());
}
} else {
System.out.println("Player is offline");
}
Last modified 1yr ago