Skip to content

How to use the API (version 2.0)

CC007 edited this page Feb 13, 2022 · 1 revision

Setup

HeadsPluginAPI has support for spring bean injection. To be able to use this in the API, you will need to provide the plugin's classloader like so:

public class MyPlugin extends JavaPlugin {
    
    ...

    @Override
    public void onLoad() {
        getLogger().info("Added class loader to HeadsPluginApi springClassLoaders");
        HeadsPluginApi.addSpringClassLoader(getClassLoader());
    }

    ...
}

Provided functionality

The api provides a multitude of functionalities. These can be accessed through methods in the HeadsPluginApi class. You can get an instance of this class like so:

HeadsPluginApi api = HeadsPluginApi.getInstance();

This API provides the following services:

Service name HeadsPluginApi method Description
CategorySearcher api.getCategorySearcher() Used for retrieving heads from categories
CategoryUpdater api.getCategoryUpdater() Used for updating categories
HeadCreator api.getHeadCreator() Used for uploading a player's head to the MineSkin.org website
HeadPlacer api.getHeadPlacer() Used for placing a head in the Minecraft world
HeadSearcher api.getHeadSearcher() Used for retrieving heads based on a search term or UUID
HeadToItemstackMapper api.getHeadToItemstackMapper() Used to turn a Head object into a Bukkit Itemstack object

For a more in depth description, you can check the API docs