PowerRanks API States

Results that are returned by (some) API functions

How to use the returned PowerRanks API State?

Firstly, import the API states in order to use those. (Not required when using a switch statement).

import nl.svenar.powerranks.api.PowerRanksAPI.POWERRANKS_API_STATE;

Example usage:

String rankName = "MyAwesomeRank";
‚Äč
switch (PowerRanks.getAPI().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;
}

Possible return states of the API

State

Description

RANK_CREATE_SUCCESSFULLY

Successfully created a new rank

RANK_CREATE_FAILED_INVALID_CHARACTERS

Failed to create a rank because it contains invalid characters

RANK_CREATE_FAILED_NAME_ALREADY_EXISTS

Failed to create a rank with that name because a rank with that name already exists

RANK_DELETE_SUCCESSFULLY

Successfully deleted an existing rank

RANK_FAILED_NAME_NOT_FOUND

Failed to find a rank with the specified name

RANK_FAILED_CANNOT_DELETE_DEFAULT_RANK

Failed attempt to delete the default rank

RANK_SET_WEIGHT_SUCCESSFULLY

Successfully changed the weight of a rank

RANK_SET_PREFIX_SUCCESSFULLY

Successfully changed the prefix of a rank

RANK_SET_SUFFIX_SUCCESSFULLY

Successfully changed the suffix of a rank

RANK_PERMISSION_ADD_SUCCESSFULLY

Successfully added a permission to a rank

RANK_PERMISSION_ADD_FAILED_PERMISSION_ALREADY_EXISTS

Failed to add a permission to a rank since that rank already has that permission

RANK_PERMISSION_ALLOWED_CHANGED_SUCCESSFULLY

Successfully changed the allowance value of a rank

RANK_FAILED_PERMISSION_NOT_FOUND

Failed to find the specified permission

RANK_PERMISSION_REMOVED_SUCCESSFULLY

Successfully removed a permission from a rank

PLAYER_FAILED_NAME_NOT_FOUND

Failed to find the specified player

PLAYER_FAILED_ALREADY_HAS_RANK

Failed to add a specified rank to a player since the player already has that rank

PLAYER_SUCCESSFULLY_SET_RANK

Successfully changed the rank of a player

PLAYER_SUCCESSFULLY_ADDED_RANK

Successfully added a rank to a player

PLAYER_SUCCESSFULLY_REMOVED_RANK

Successfully removed a rank from a player

PLAYER_FAILED_DOES_NOT_HAVE_RANK

Failed to find a specific rank on a player

PLAYER_SUCCESSFULLY_REMOVED_ALL_RANKS

Successfully removed all ranks from a player except the default rank