Services
Services let plugins share functionality through an interface. Register a provider with a priority, and look it up by type. Service access belongs on the server thread.
package dev.example;
import dev.zernyth.api.plugin.JavaPlugin;
import dev.zernyth.api.service.ServicePriority;
public final class GreeterPlugin extends JavaPlugin {
public interface Greeter { String greet(String name); }
@Override
public void onEnable() {
var services = getServer().getServicesManager();
services.register(Greeter.class, name -> "Hello " + name, ServicePriority.NORMAL);
services.find(Greeter.class).ifPresent(greeter -> getLogger().info(greeter.greet("world")));
}
}find returns an Optional, load is the direct form, and getProviders lists every provider. register returns a Registration that you can close. To share the interface across plugins, put it in an exported package and import it from the consuming plugin. See Dependency Management.