Skip to content

Developer API

Andrew Tran edited this page Feb 5, 2018 · 4 revisions

Developer API

If you want to use MoreStorage's API, you must first get an instance of MoreStorage. Before you even do that though, you'll want to check if MoreStorage is running. Either soft-depend or depend on MoreStorage in your plugin.yml, if you soft-depend you'll need to check if the retrieved MoreStorage instance is null. You can retrieve an instance of MoreStorage through the PluginManager.

Example Code

package my.plugin;

import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.Plugin;
import me.andrew28.morestorage.MoreStorage;

public class MyPlugin extends JavaPlugin {
    private MoreStorage moreStorage;

    @Override
    public void onEnable() {
        Plugin moreStoragePlugin = getServer().getPluginManager().getPlugin("MoreStorage");
        // Null check is only needed if you're 'soft-depend'ing instead of 'depend'ing
        if (moreStoragePlugin == null) {
            getLogger().warning("You need the MoreStorage plugin to use this plugin")
            return;
        }   
        moreStorage = (MoreStorage) moreStoragePlugin;
        // Now you can use moreStorage!
    }
}

Javadocs

Javadocs can be found at this link.

Clone this wiki locally