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;
}
}
Aggregations