summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2014-02-15 11:17:14 -0600
committerWesley Wolfe <weswolf@aol.com>2014-02-15 12:12:13 -0600
commit7b04f0a6cd217e638f2dfaf676b7e7cf4712181e (patch)
treee9bb9f87c1e5deb38707c19eb14a5612413cee4c /src
parentb18e28ab4f89df1ad8e14c2d7d9483ecddb9c892 (diff)
downloadbukkit-7b04f0a6cd217e638f2dfaf676b7e7cf4712181e.tar
bukkit-7b04f0a6cd217e638f2dfaf676b7e7cf4712181e.tar.gz
bukkit-7b04f0a6cd217e638f2dfaf676b7e7cf4712181e.tar.lz
bukkit-7b04f0a6cd217e638f2dfaf676b7e7cf4712181e.tar.xz
bukkit-7b04f0a6cd217e638f2dfaf676b7e7cf4712181e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/plugin/PluginDescriptionFile.java69
-rw-r--r--src/main/java/org/bukkit/plugin/SimplePluginManager.java6
2 files changed, 28 insertions, 47 deletions
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
index 0d1e3a04..18f31bff 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -169,9 +169,9 @@ public final class PluginDescriptionFile {
private String name = null;
private String main = null;
private String classLoaderOf = null;
- private List<String> depend = null;
- private List<String> softDepend = null;
- private List<String> loadBefore = null;
+ private List<String> depend = ImmutableList.of();
+ private List<String> softDepend = ImmutableList.of();
+ private List<String> loadBefore = ImmutableList.of();
private String version = null;
private Map<String, Map<String, Object>> commands = null;
private String description = null;
@@ -863,47 +863,9 @@ public final class PluginDescriptionFile {
classLoaderOf = map.get("class-loader-of").toString();
}
- if (map.get("depend") != null) {
- ImmutableList.Builder<String> dependBuilder = ImmutableList.<String>builder();
- try {
- 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();
- }
+ depend = makePluginNameList(map, "depend");
+ softDepend = makePluginNameList(map, "softdepend");
+ loadBefore = makePluginNameList(map, "loadbefore");
if (map.get("database") != null) {
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() {
Map<String, Object> map = new HashMap<String, Object>();
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 787dcfe5..7d8a281e 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -144,7 +144,7 @@ public final class SimplePluginManager implements PluginManager {
plugins.put(description.getName(), file);
Collection<String> softDependencySet = description.getSoftDepend();
- if (softDependencySet != null) {
+ if (softDependencySet != null && !softDependencySet.isEmpty()) {
if (softDependencies.containsKey(description.getName())) {
// Duplicates do not matter, they will be removed together if applicable
softDependencies.get(description.getName()).addAll(softDependencySet);
@@ -154,12 +154,12 @@ public final class SimplePluginManager implements PluginManager {
}
Collection<String> dependencySet = description.getDepend();
- if (dependencySet != null) {
+ if (dependencySet != null && !dependencySet.isEmpty()) {
dependencies.put(description.getName(), new LinkedList<String>(dependencySet));
}
Collection<String> loadBeforeSet = description.getLoadBefore();
- if (loadBeforeSet != null) {
+ if (loadBeforeSet != null && !loadBeforeSet.isEmpty()) {
for (String loadBeforeTarget : loadBeforeSet) {
if (softDependencies.containsKey(loadBeforeTarget)) {
softDependencies.get(loadBeforeTarget).add(description.getName());