API

RPPRofessions has an easy-to-access API.

Accessing The API

Accessing the plugin API is very easy. Simply check that the plugin exists on the server and then set a field/variable equal to the plugin's API:

private RPProfessionsAPI rpProfessionsAPI;

//Some code if needed

private void loadRPProfessions() {
    if(Bukkit.getServer().getPluginManager().isPluginEnabled("RPProfessions")) {
        rpProfessionsAPI = RPProfessions.getAPI();
    }
}

Using the API

Now that you have access to the plugin's API, you can view and use the exposed methods.

Here are the available methods. Should you need more than what's already inside the RPPRofessionsAPI class please open a ticket in the issue section of RPProfessions' public repository.

/**
 * Get the ProfessionItem instance matching the given id if one exists.
 *
 * @param id the RPProfessions item id
 * @return an optional of an instance of ProfessionItem
 */
public Optional<ProfessionItem> getProfessionItem(@NotNull final String id);

/**
 * Get the item stack matching the given RPProfessions item id if one exists.
 *
 * @param id the RPProfessions item id
 * @return an optional of an instance of ItemStack
 */
public Optional<ItemStack> getItemStack(@NotNull final String id);

/**
* Get the RecipePattern instance matching the given RPProfessions item id if that item has a pattern.
*
* @param id the RPProfessions item id to get the pattern from
* @return an optional of an instance of RecipePattern
*/
public Optional<RecipePattern> getPattern(@NotNull final String id);

/**
* Get the pattern's item stack matching the given RPProfessions item id if that item has a pattern.
*
* @param id the RPProfessions item id to get the pattern from
* @return an optional of an instance of ItemStack
*/
public Optional<ItemStack> getPatternItemStack(@NotNull final String id);

/**
 * Get the player's profession if it has one.
*
* @param player the player to get the profession from
* @return an instance of Profession
*/
public Optional<Profession> getPlayerProfession(@NotNull final Player player);
	
/**
* Get the player's profession level or -1 if the player has no profession.
*
* @param player the player to get the profession level from
* @return the player's profession level as an integer
*/
public int getPlayerProfessionLevel(@NotNull final Player player);

Last updated