Search in sources :

Example 6 with PluginDependency

use of org.spongepowered.plugin.meta.PluginDependency in project LanternServer by LanternPowered.

the class PluginCandidate method collectOptionalDependencies.

private void collectOptionalDependencies(@Nullable Iterable<PluginDependency> dependencies, Map<String, PluginContainer> loadedPlugins, Map<String, PluginCandidate> candidates) {
    if (dependencies == null) {
        return;
    }
    for (PluginDependency dependency : dependencies) {
        final String id = dependency.getId();
        if (this.id.equals(id)) {
            Lantern.getLogger().error("Plugin '{}' from {} cannot have a dependency on itself. This is redundant and should be " + "removed.", this.id, getDisplaySource());
            this.invalid = true;
            continue;
        }
        final String version = dependency.getVersion();
        final PluginContainer loaded = loadedPlugins.get(id);
        if (loaded != null) {
            if (!verifyVersionRange(id, version, loaded.getVersion().orElse(null))) {
                this.missingRequirements.put(id, version);
            }
            continue;
        }
        final PluginCandidate candidate = candidates.get(id);
        if (candidate != null) {
            if (verifyVersionRange(id, version, candidate.getMetadata().getVersion())) {
                this.dependencies.add(candidate);
            } else {
                this.missingRequirements.put(id, version);
            }
        }
    }
}
Also used : PluginDependency(org.spongepowered.plugin.meta.PluginDependency) PluginContainer(org.spongepowered.api.plugin.PluginContainer)

Aggregations

PluginDependency (org.spongepowered.plugin.meta.PluginDependency)6 HashSet (java.util.HashSet)3 Set (java.util.Set)2 PluginContainer (org.spongepowered.api.plugin.PluginContainer)2 Nullable (javax.annotation.Nullable)1 Dependency (org.spongepowered.api.plugin.Dependency)1 InvalidVersionSpecificationException (org.spongepowered.plugin.meta.version.InvalidVersionSpecificationException)1