geforkt von Mirrors/Paper
Fix ClassCastException for malformed plugin.yml. Fixes BUKKIT-3563
If the plugin.yml gets loaded but wasn't in the form of a map, the server would crash. This safely checks to see if it can be cast, throwing invalid description if it cannot. By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Ursprung
98622c3c7a
Commit
c23f9be8d3
@ -39,7 +39,7 @@ public final class PluginDescriptionFile {
|
||||
private PermissionDefault defaultPerm = PermissionDefault.OP;
|
||||
|
||||
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
|
||||
loadMap((Map<?, ?>) yaml.load(stream));
|
||||
loadMap(asMap(yaml.load(stream)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ public final class PluginDescriptionFile {
|
||||
* @throws InvalidDescriptionException If the PluginDescriptionFile is invalid
|
||||
*/
|
||||
public PluginDescriptionFile(final Reader reader) throws InvalidDescriptionException {
|
||||
loadMap((Map<?, ?>) yaml.load(reader));
|
||||
loadMap(asMap(yaml.load(reader)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,4 +400,11 @@ public final class PluginDescriptionFile {
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<?,?> asMap(Object object) throws InvalidDescriptionException {
|
||||
if (object instanceof Map) {
|
||||
return (Map<?,?>) object;
|
||||
}
|
||||
throw new InvalidDescriptionException(object + " is not properly structured.");
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren