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:
privateRPProfessionsAPI rpProfessionsAPI;//Some code if neededprivatevoidloadRPProfessions() {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 */publicOptional<ProfessionItem>getProfessionItem(@NotNullfinalString 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 */publicOptional<ItemStack>getItemStack(@NotNullfinalString 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*/publicOptional<RecipePattern>getPattern(@NotNullfinalString 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*/publicOptional<ItemStack>getPatternItemStack(@NotNullfinalString id);/** * Get the player's profession if it has one.** @param player the player to get the profession from* @return an instance of Profession*/publicOptional<Profession>getPlayerProfession(@NotNullfinalPlayer 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*/publicintgetPlayerProfessionLevel(@NotNullfinalPlayer player);