Fix loadbefore, soft, and normal dependencies with spaces. Fixes BUKKIT-5418
This change makes the lists of loadbefore, softdependency, and dependency replace the spaces in the names with underscored to reflect the behavior used with names.
This commit is contained in:
@@ -169,9 +169,9 @@ public final class PluginDescriptionFile {
|
|||||||
private String name = null;
|
private String name = null;
|
||||||
private String main = null;
|
private String main = null;
|
||||||
private String classLoaderOf = null;
|
private String classLoaderOf = null;
|
||||||
private List<String> depend = null;
|
private List<String> depend = ImmutableList.of();
|
||||||
private List<String> softDepend = null;
|
private List<String> softDepend = ImmutableList.of();
|
||||||
private List<String> loadBefore = null;
|
private List<String> loadBefore = ImmutableList.of();
|
||||||
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;
|
||||||
@@ -863,47 +863,9 @@ public final class PluginDescriptionFile {
|
|||||||
classLoaderOf = map.get("class-loader-of").toString();
|
classLoaderOf = map.get("class-loader-of").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.get("depend") != null) {
|
depend = makePluginNameList(map, "depend");
|
||||||
ImmutableList.Builder<String> dependBuilder = ImmutableList.<String>builder();
|
softDepend = makePluginNameList(map, "softdepend");
|
||||||
try {
|
loadBefore = makePluginNameList(map, "loadbefore");
|
||||||
for (Object dependency : (Iterable<?>) map.get("depend")) {
|
|
||||||
dependBuilder.add(dependency.toString());
|
|
||||||
}
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
throw new InvalidDescriptionException(ex, "depend is of wrong type");
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
throw new InvalidDescriptionException(e, "invalid dependency format");
|
|
||||||
}
|
|
||||||
depend = dependBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map.get("softdepend") != null) {
|
|
||||||
ImmutableList.Builder<String> softDependBuilder = ImmutableList.<String>builder();
|
|
||||||
try {
|
|
||||||
for (Object dependency : (Iterable<?>) map.get("softdepend")) {
|
|
||||||
softDependBuilder.add(dependency.toString());
|
|
||||||
}
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
throw new InvalidDescriptionException(ex, "softdepend is of wrong type");
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
throw new InvalidDescriptionException(ex, "invalid soft-dependency format");
|
|
||||||
}
|
|
||||||
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 {
|
||||||
@@ -973,6 +935,25 @@ public final class PluginDescriptionFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<String> makePluginNameList(final Map<?, ?> map, final String key) throws InvalidDescriptionException {
|
||||||
|
final Object value = map.get(key);
|
||||||
|
if (value == null) {
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
final ImmutableList.Builder<String> builder = ImmutableList.<String>builder();
|
||||||
|
try {
|
||||||
|
for (final Object entry : (Iterable<?>) value) {
|
||||||
|
builder.add(entry.toString().replace(' ', '_'));
|
||||||
|
}
|
||||||
|
} catch (ClassCastException ex) {
|
||||||
|
throw new InvalidDescriptionException(ex, key + " is of wrong type");
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
throw new InvalidDescriptionException(ex, "invalid " + key + " format");
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Object> saveMap() {
|
private Map<String, Object> saveMap() {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public final class SimplePluginManager implements PluginManager {
|
|||||||
plugins.put(description.getName(), file);
|
plugins.put(description.getName(), file);
|
||||||
|
|
||||||
Collection<String> softDependencySet = description.getSoftDepend();
|
Collection<String> softDependencySet = description.getSoftDepend();
|
||||||
if (softDependencySet != null) {
|
if (softDependencySet != null && !softDependencySet.isEmpty()) {
|
||||||
if (softDependencies.containsKey(description.getName())) {
|
if (softDependencies.containsKey(description.getName())) {
|
||||||
// Duplicates do not matter, they will be removed together if applicable
|
// Duplicates do not matter, they will be removed together if applicable
|
||||||
softDependencies.get(description.getName()).addAll(softDependencySet);
|
softDependencies.get(description.getName()).addAll(softDependencySet);
|
||||||
@@ -154,12 +154,12 @@ public final class SimplePluginManager implements PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collection<String> dependencySet = description.getDepend();
|
Collection<String> dependencySet = description.getDepend();
|
||||||
if (dependencySet != null) {
|
if (dependencySet != null && !dependencySet.isEmpty()) {
|
||||||
dependencies.put(description.getName(), new LinkedList<String>(dependencySet));
|
dependencies.put(description.getName(), new LinkedList<String>(dependencySet));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<String> loadBeforeSet = description.getLoadBefore();
|
Collection<String> loadBeforeSet = description.getLoadBefore();
|
||||||
if (loadBeforeSet != null) {
|
if (loadBeforeSet != null && !loadBeforeSet.isEmpty()) {
|
||||||
for (String loadBeforeTarget : loadBeforeSet) {
|
for (String loadBeforeTarget : loadBeforeSet) {
|
||||||
if (softDependencies.containsKey(loadBeforeTarget)) {
|
if (softDependencies.containsKey(loadBeforeTarget)) {
|
||||||
softDependencies.get(loadBeforeTarget).add(description.getName());
|
softDependencies.get(loadBeforeTarget).add(description.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user