All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yungnickyoung.minecraft.yungsapi.services.Services Maven / Gradle / Ivy

There is a newer version: 1.21.1-NeoForge-5.1.2
Show 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy