Search in sources :

Example 1 with PluginFileConfigurable

use of org.spongepowered.forge.applaunch.loading.metadata.PluginFileConfigurable in project SpongeCommon by SpongePowered.

the class ModFileParsers method pluginMetadataParser.

public static IModFileInfo pluginMetadataParser(final String fileName, final IModFile iModFile) {
    final ModFile modFile = (ModFile) iModFile;
    AppLaunch.logger().debug("Considering plugin file candidate {}", modFile.getFilePath());
    final Path metadataFile = modFile.getLocator().findPath(modFile, "META-INF/" + fileName + ".json");
    if (Files.notExists(metadataFile)) {
        AppLaunch.logger().debug("Plugin file '{}' is missing a 'sponge_plugins.json' metadata file in META-INF", modFile);
        return null;
    }
    try {
        final MetadataContainer container;
        try (final Reader reader = Files.newBufferedReader(metadataFile, StandardCharsets.UTF_8)) {
            container = MetadataParser.read(reader);
        }
        final PluginFileConfigurable configurable = new PluginFileConfigurable(container);
        return ModFileParsers.generateModFileMetadata(modFile, configurable);
    } catch (final Exception e) {
        AppLaunch.logger().warn("Could not read metadata for plugin file '{}'", modFile, e);
        return null;
    }
}
Also used : Path(java.nio.file.Path) ModFile(net.minecraftforge.fml.loading.moddiscovery.ModFile) IModFile(net.minecraftforge.forgespi.locating.IModFile) MetadataContainer(org.spongepowered.plugin.metadata.builtin.MetadataContainer) PluginFileConfigurable(org.spongepowered.forge.applaunch.loading.metadata.PluginFileConfigurable) Reader(java.io.Reader)

Aggregations

Reader (java.io.Reader)1 Path (java.nio.file.Path)1 ModFile (net.minecraftforge.fml.loading.moddiscovery.ModFile)1 IModFile (net.minecraftforge.forgespi.locating.IModFile)1 PluginFileConfigurable (org.spongepowered.forge.applaunch.loading.metadata.PluginFileConfigurable)1 MetadataContainer (org.spongepowered.plugin.metadata.builtin.MetadataContainer)1