mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
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:
parent
b18e28ab4f
commit
7b04f0a6cd
2 changed files with 28 additions and 47 deletions
|
@ -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>();
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue