Search in sources :

Example 1 with LaunchException

use of org.spongepowered.server.launch.LaunchException in project SpongeVanilla by SpongePowered.

the class MetadataContainer method load.

public static MetadataContainer load(String path) {
    List<PluginMetadata> meta;
    path = path + '/' + McModInfo.STANDARD_FILENAME;
    try (InputStream in = MetadataContainer.class.getResourceAsStream(path)) {
        if (in == null) {
            if (VanillaLaunch.ENVIRONMENT != DEVELOPMENT) {
                throw new LaunchException("Unable to find metadata file at " + path);
            }
            return new MetadataContainer(ImmutableMap.of());
        }
        meta = McModInfo.DEFAULT.read(in);
    } catch (IOException e) {
        throw new LaunchException("Failed to load metadata", e);
    }
    ImmutableMap.Builder<String, PluginMetadata> builder = ImmutableMap.builder();
    for (PluginMetadata m : meta) {
        builder.put(m.getId(), m);
    }
    return new MetadataContainer(builder.build());
}
Also used : LaunchException(org.spongepowered.server.launch.LaunchException) InputStream(java.io.InputStream) PluginMetadata(org.spongepowered.plugin.meta.PluginMetadata) IOException(java.io.IOException) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PluginMetadata (org.spongepowered.plugin.meta.PluginMetadata)1 LaunchException (org.spongepowered.server.launch.LaunchException)1