13
0
geforkt von Mirrors/Paper

[Bleeding] Added loadbefore property; Addresses BUKKIT-843

By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-03-20 03:54:51 -05:00
Ursprung 791dd4c428
Commit 8874c4e872
2 geänderte Dateien mit 43 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ public final class PluginDescriptionFile {
private String classLoaderOf = null; private String classLoaderOf = null;
private List<String> depend = null; private List<String> depend = null;
private List<String> softDepend = null; private List<String> softDepend = null;
private List<String> loadBefore = null;
private String version = null; private String version = null;
private Map<String, Map<String, Object>> commands = null; private Map<String, Map<String, Object>> commands = null;
private String description = null; private String description = null;
@ -121,6 +122,14 @@ public final class PluginDescriptionFile {
return softDepend; 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() { public PluginLoadOrder getLoad() {
return order; return order;
} }
@ -267,6 +276,20 @@ public final class PluginDescriptionFile {
softDepend = softDependBuilder.build(); 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) { if (map.get("database") != null) {
try { try {
database = (Boolean) map.get("database"); database = (Boolean) map.get("database");

Datei anzeigen

@ -139,13 +139,32 @@ public final class SimplePluginManager implements PluginManager {
Collection<String> softDependencySet = description.getSoftDepend(); Collection<String> softDependencySet = description.getSoftDepend();
if (softDependencySet != null) { 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(); Collection<String> dependencySet = description.getDepend();
if (dependencySet != null) { if (dependencySet != null) {
dependencies.put(description.getName(), new LinkedList<String>(dependencySet)); 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()) { while (!plugins.isEmpty()) {
@ -227,7 +246,6 @@ public final class SimplePluginManager implements PluginManager {
if (!dependencies.containsKey(plugin)) { if (!dependencies.containsKey(plugin)) {
softDependencies.remove(plugin); softDependencies.remove(plugin);
dependencies.remove(plugin);
missingDependency = false; missingDependency = false;
File file = plugins.get(plugin); File file = plugins.get(plugin);
pluginIterator.remove(); pluginIterator.remove();