Search in sources :

Example 1 with NightConfigWrapper

use of net.minecraftforge.fml.loading.moddiscovery.NightConfigWrapper in project SpongeCommon by SpongePowered.

the class ModFileParsers method dummySpongeModParser.

public static IModFileInfo dummySpongeModParser(final IModFile realModFile, final String fileName, final IModFile iModFile) {
    final ModFile modFile = (ModFile) iModFile;
    AppLaunch.logger().debug("Considering sponge platform candidate {}", modFile.getFilePath());
    final Path modsjson = modFile.getLocator().findPath(realModFile, fileName + ".toml");
    if (!Files.exists(modsjson)) {
        AppLaunch.logger().warn("Sponge platform file '{}' is missing the '{}' file", modFile, fileName + ".toml");
        return null;
    } else {
        final FileConfig fileConfig = FileConfig.builder(modsjson).build();
        fileConfig.load();
        fileConfig.close();
        final NightConfigWrapper configWrapper = new NightConfigWrapper(fileConfig);
        try {
            return ModFileParsers.generateModFileMetadata(modFile, configWrapper);
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : Path(java.nio.file.Path) FileConfig(com.electronwill.nightconfig.core.file.FileConfig) ModFile(net.minecraftforge.fml.loading.moddiscovery.ModFile) IModFile(net.minecraftforge.forgespi.locating.IModFile) NightConfigWrapper(net.minecraftforge.fml.loading.moddiscovery.NightConfigWrapper)

Example 2 with NightConfigWrapper

use of net.minecraftforge.fml.loading.moddiscovery.NightConfigWrapper in project SpongeCommon by SpongePowered.

the class ModFileParsers method generateModFileMetadata.

private static ModFileInfo generateModFileMetadata(final ModFile file, final IConfigurable configurable) throws Exception {
    ModFileParsers.modFileInfoConstructor.setAccessible(true);
    final ModFileInfo modFileInfo = ModFileParsers.modFileInfoConstructor.newInstance(file, configurable);
    ModFileParsers.modFileInfoConstructor.setAccessible(false);
    if (configurable instanceof NightConfigWrapper) {
        ModFileParsers.modFileInfoField.setAccessible(true);
        ModFileParsers.modFileInfoField.set(configurable, modFileInfo);
        ModFileParsers.modFileInfoField.setAccessible(false);
    }
    return modFileInfo;
}
Also used : IModFileInfo(net.minecraftforge.forgespi.language.IModFileInfo) ModFileInfo(net.minecraftforge.fml.loading.moddiscovery.ModFileInfo) NightConfigWrapper(net.minecraftforge.fml.loading.moddiscovery.NightConfigWrapper)

Aggregations

NightConfigWrapper (net.minecraftforge.fml.loading.moddiscovery.NightConfigWrapper)2 FileConfig (com.electronwill.nightconfig.core.file.FileConfig)1 Path (java.nio.file.Path)1 ModFile (net.minecraftforge.fml.loading.moddiscovery.ModFile)1 ModFileInfo (net.minecraftforge.fml.loading.moddiscovery.ModFileInfo)1 IModFileInfo (net.minecraftforge.forgespi.language.IModFileInfo)1 IModFile (net.minecraftforge.forgespi.locating.IModFile)1