Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Getting an instance of PlotSquared

DJtheRedstoner edited this page Aug 12, 2019 · 8 revisions

This guide is for PlotSquared versions <= 1.12.2

import com.intellectualcrafters.plot.api.PlotAPI;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;

public class Main extends JavaPlugin {
    public PlotAPI api;

    @Override
    public void onEnable() {
        PluginManager manager = Bukkit.getServer().getPluginManager();
        final Plugin plotsquared = manager.getPlugin("PlotSquared");

        // Disable the plugin if PlotSquared is not installed

        // If you move any PlotSquared related tasks to an external class you 
        // wouldn't have to disable the plugin if PlotSquared wasn't installed

        if(plotsquared != null && !plotsquared.isEnabled()) {
            PS.log(null, "&c[ExamplePlugin] Could not find PlotSquared! Disabling plugin...");
            manager.disablePlugin(this);
            return;
        }

        // Do PlotSquared related stuff
        api = new PlotAPI();

        // You can now use this api object to do powerful things.
    }
}

Clone this wiki locally