com.yungnickyoung.minecraft.yungsapi.services.Services Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of YungsApi Show documentation
Show all versions of YungsApi Show documentation
A common API for YUNG's Minecraft mods
The newest version!
package com.yungnickyoung.minecraft.yungsapi.services;
import com.yungnickyoung.minecraft.yungsapi.YungsApiCommon;
import java.util.ServiceLoader;
public class Services {
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
public static final IAutoRegisterHelper AUTO_REGISTER = load(IAutoRegisterHelper.class);
public static final IBlockEntityTypeHelper BLOCK_ENTITY_TYPE_HELPER = load(IBlockEntityTypeHelper.class);
public static T load(Class clazz) {
final T loadedService = ServiceLoader.load(clazz)
.findFirst()
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName()));
YungsApiCommon.LOGGER.debug("Loaded {} for service {}", loadedService, clazz);
return loadedService;
}
}