Getting Started

How to set-up the PowerRanks API

Get an API instance in Java

To get access to the API use the following line:

import nl.svenar.powerranks.PowerRanks;
import nl.svenar.powerranks.api.PowerRanksAPI;
PowerRanksAPI api = PowerRanks.getAPI();

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

String rankName = "MyAwesomeRank";
switch (api.createRank(rankName)) {
case RANK_CREATE_FAILED_INVALID_CHARACTERS:
System.out.println("The rankname contains invalid characters!");
break;
case RANK_CREATE_FAILED_NAME_ALREADY_EXISTS:
System.out.println("A rank called '" + rankName + "' already exists!");
break;
case RANK_CREATE_SUCCESSFULLY:
System.out.println("The rank has been created!");
break;
default:
break;
}

Add a rank to a player

String rankName = "MyAwesomeRank";
String playerName = "svenar";
switch (api.addPlayerRank(playerName, rankName)) {
case PLAYER_FAILED_NAME_NOT_FOUND:
System.out.println("A player by that name is not found!");
break;
case RANK_FAILED_NAME_NOT_FOUND:
System.out.println("A rank by that name is not found!");
break;
case PLAYER_FAILED_ALREADY_HAS_RANK:
System.out.println("The player already has that rank!");
break;
case PLAYER_SUCCESSFULLY_SET_RANK:
System.out.println("The rank has been added to the player!");
break;
default:
break;
}