Setup/API

Developer API documentation



SpectatorPlus


The API was added in SpectatorPlus S1.9.1, however it didn't work until version 1.9.2.

To use the API in your plugin, first download the plugin from here and add it into your project. Then you need to check to make sure SpectatorPlus is actually running on the server:

// Ensure the plugin is loaded
Plugin spTest = Bukkit.getServer().getPluginManager().getPlugin("SpectatorPlus");
if(spTest == null || !spTest.isEnabled()) {
    return;
}

Then you can grab your reference to the API and start using it:

SpectateAPI api = ((SpectatorPlus) spTest).getAPI();

Some things you can do with the API:

if(api.isSpectator(player)) { // Check if 'player' is spectating
    // ...
}
api.setSpectating(player, true); // Turn on/off spectate mode for 'player'
api.setCompass(true, true); // Edit the values of each item in toggles.yml

The JavaDoc of this API is available here.