-
Notifications
You must be signed in to change notification settings - Fork 3
Developer API
Jeremiah Osborne edited this page Jun 5, 2020
·
1 revision
In order to properly use DisplayShopsAPI you will need to be able to retrieve the plugin's instance. You can do this by following these instructions:
- Download the DisplayShopsAPI JAR from the releases tab and add it to your plugin's dependencies.
- Make sure your plugin can grab the plugin's instance from your Main class file like below:
import xzot1k.plugins.ds.DisplayShopsAPI;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
public class Main extends JavaPlugin
{
private static DisplayShopsAPI displayShopsAPI;
@Override
public void onEnable()
{
if (!isDisplayShopsInstalled())
{
getServer().getPluginManager().disablePlugin(this);
return; // This plugin is now disabled since DS was not installed.
}
// DS was found and now can be accessed with the getDisplayShops() getter.
}
// This method tells you whether DS is installed or not.
private boolean isDisplayShopsInstalled()
{
DisplayShops ds = (DisplayShops) getServer().getPluginManager().getPlugin("DisplayShops");
if(ds != null)
{
setDisplayShops(ds);
return true;
}
return false;
}
public static DisplayShops getDisplayShops() { return displayShopsAPI; }
private static void setDisplayShops(DisplayShops ptg) { Main.displayShopsAPI = displayShopsAPI; }
}
- Once 1 and 2 are completed, add "depend: [DisplayShops]" or related things inside your plugin.yml (This step is optional, but never hurts to make sure DisplayShops is installed).
- Everything should be all set. As a test, call the getDisplayShops() method from your Main class and you will be able to access each piece of the API. The main point of access in terms of existing shops and helpful methods is the getManager() method found in inside the DisplayShops interface or DisplayShopsAPI class.
Wiki
General Help
Configuration
Advanced Help
DisplayShops 2.0
I Need Help!