diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/plugin/PluginDescriptionFile.java | 23 | ||||
-rw-r--r-- | src/main/java/org/bukkit/plugin/SimplePluginManager.java | 22 |
2 files changed, 43 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index 21858eb5..09e22ccb 100644 --- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -25,6 +25,7 @@ public final class PluginDescriptionFile { private String classLoaderOf = null; private List<String> depend = null; private List<String> softDepend = null; + private List<String> loadBefore = null; private String version = null; private Map<String, Map<String, Object>> commands = null; private String description = null; @@ -121,6 +122,14 @@ public final class PluginDescriptionFile { return softDepend; } + /** + * Gets the list of plugins that should consider this plugin a soft-dependency + * @return immutable list of plugins that should consider this plugin a soft-dependency + */ + public List<String> getLoadBefore() { + return softDepend; + } + public PluginLoadOrder getLoad() { return order; } @@ -267,6 +276,20 @@ public final class PluginDescriptionFile { softDepend = softDependBuilder.build(); } + if (map.get("loadbefore") != null) { + ImmutableList.Builder<String> loadBeforeBuilder = ImmutableList.<String>builder(); + try { + for (Object predependency : (Iterable<?>) map.get("loadbefore")) { + loadBeforeBuilder.add(predependency.toString()); + } + } catch (ClassCastException ex) { + throw new InvalidDescriptionException(ex, "loadbefore is of wrong type"); + } catch (NullPointerException ex) { + throw new InvalidDescriptionException(ex, "invalid load-before format"); + } + loadBefore = loadBeforeBuilder.build(); + } + if (map.get("database") != null) { try { database = (Boolean) map.get("database"); diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java index f23a59e2..6a366ef9 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -139,13 +139,32 @@ public final class SimplePluginManager implements PluginManager { Collection<String> softDependencySet = description.getSoftDepend(); if (softDependencySet != null) { - softDependencies.put(description.getName(), new LinkedList<String>(softDependencySet)); + if (softDependencies.containsKey(description.getName())) { + // Duplicates do not matter, they will be removed together if applicable + softDependencies.get(description.getName()).addAll(softDependencySet); + } else { + softDependencies.put(description.getName(), new LinkedList<String>(softDependencySet)); + } } Collection<String> dependencySet = description.getDepend(); if (dependencySet != null) { dependencies.put(description.getName(), new LinkedList<String>(dependencySet)); } + + Collection<String> loadBeforeSet = description.getLoadBefore(); + if (loadBeforeSet != null) { + for (String loadBeforeTarget : loadBeforeSet) { + if (softDependencies.containsKey(loadBeforeTarget)) { + softDependencies.get(loadBeforeTarget).add(description.getName()); + } else { + // softDependencies is never iterated, so 'ghost' plugins aren't an issue + Collection<String> shortSoftDependency = new LinkedList<String>(); + shortSoftDependency.add(description.getName()); + softDependencies.put(loadBeforeTarget, shortSoftDependency); + } + } + } } while (!plugins.isEmpty()) { @@ -227,7 +246,6 @@ public final class SimplePluginManager implements PluginManager { if (!dependencies.containsKey(plugin)) { softDependencies.remove(plugin); - dependencies.remove(plugin); missingDependency = false; File file = plugins.get(plugin); pluginIterator.remove(); |