Hi, I have made a plugin (provider) which has some functionality that I want to access via another plugin I am making (consumer). To make this work, I have made a third plugin which is supposed to act as an API for the provider.
The API project consists of an empty main class and an Interface which looks like this:
public interface AurumAPI {
UUID spawnMobAtLocation(Location location, String mobName);
void openDoorAtLocation(Location location);
void clearTokensFromPlayer(Player player);
}
The provider has a class called APIProvider which implements the methods outlined in the api which looks like this:
public class APIProvider implements AurumAPI {
......
}
I am then using the bukkit service manager to register that class so that i can access it in my consumer like this:
Bukkit.getServicesManager().register(AurumAPI.class, new APIProvider(), plugin, ServicePriority.Normal);
After that i have made a check to see if it was properly registered like this getLogger().info("AurumAPI registered: " + Bukkit.getServicesManager().isProvidedFor(AurumAPI.class)); which returns true, so thats working fine.
In my consumer i then try to access the service like this in my onEnable:
aurumAPI = Bukkit.getServicesManager().load(AurumAPI.class);
if (aurumAPI == null) {
getLogger().warning("Failed to load AurumAPI!");
}
Here the aurumAPI == null check always returns true which also means that i can use any of the functionality.
Does anyone know what I am doing wrong or if my whole approach is just incorrect?