13
0
geforkt von Mirrors/Paper

[Bleeding] More lenient command creation from plugin.yml. Fixes BUKKIT-1093

By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-03-10 13:11:21 -06:00
Ursprung c0a94420f6
Commit 71a60b4c11

Datei anzeigen

@ -202,24 +202,26 @@ public final class PluginDescriptionFile {
try { try {
for (Map.Entry<?, ?> command : ((Map<?, ?>) map.get("commands")).entrySet()) { for (Map.Entry<?, ?> command : ((Map<?, ?>) map.get("commands")).entrySet()) {
ImmutableMap.Builder<String, Object> commandBuilder = ImmutableMap.<String, Object>builder(); ImmutableMap.Builder<String, Object> commandBuilder = ImmutableMap.<String, Object>builder();
for (Map.Entry<?, ?> commandEntry : ((Map<?, ?>) command.getValue()).entrySet()) { if (command.getValue() != null) {
if (commandEntry.getValue() instanceof Iterable) { for (Map.Entry<?, ?> commandEntry : ((Map<?, ?>) command.getValue()).entrySet()) {
// This prevents internal alias list changes if (commandEntry.getValue() instanceof Iterable) {
ImmutableList.Builder<Object> commandSubList = ImmutableList.<Object>builder(); // This prevents internal alias list changes
for (Object commandSubListItem : (Iterable<?>) commandEntry.getValue()) { ImmutableList.Builder<Object> commandSubList = ImmutableList.<Object>builder();
commandSubList.add(commandSubListItem); for (Object commandSubListItem : (Iterable<?>) commandEntry.getValue()) {
if (commandSubListItem != null) {
commandSubList.add(commandSubListItem);
}
}
commandBuilder.put(commandEntry.getKey().toString(), commandSubList.build());
} else if (commandEntry.getValue() != null) {
commandBuilder.put(commandEntry.getKey().toString(), commandEntry.getValue());
} }
commandBuilder.put(commandEntry.getKey().toString(), commandSubList.build());
} else if (commandEntry.getValue() != null) {
commandBuilder.put(commandEntry.getKey().toString(), commandEntry.getValue());
} }
} }
commandsBuilder.put(command.getKey().toString(), commandBuilder.build()); commandsBuilder.put(command.getKey().toString(), commandBuilder.build());
} }
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
throw new InvalidDescriptionException(ex, "commands are of wrong type"); throw new InvalidDescriptionException(ex, "commands are of wrong type");
} catch (NullPointerException ex) {
throw new InvalidDescriptionException(ex, "commands are not properly defined");
} }
commands = commandsBuilder.build(); commands = commandsBuilder.build();
} }