public class Main extends JavaPlugin {
private IMiniPvpApi miniPvpApi;
@Override
public void onEnable() {
if (!initMiniPvpApi()){
Bukkit.getLogger().severe("Please download T-MiniPvP!");
getServer().getPluginManager().disablePlugin(this);
return;
}
}
public IMiniPvpApi getMiniPvpApi() {
return miniPvpApi;
}
private boolean initMiniPvpApi() {
if (getServer().getPluginManager().getPlugin("T-MiniPvP") == null) {
return false;
}
RegisteredServiceProvider<IMiniPvpApi> registeredServiceProvider = getServer().getServicesManager().getRegistration(IMiniPvpApi.class);
if (registeredServiceProvider == null) {
return false;
}
miniPvpApi = registeredServiceProvider.getProvider();
return miniPvpApi != null;
}
}