Fix defaults not being added properly

This commit is contained in:
Frank van der Heijden 2020-06-27 10:58:44 +02:00
parent 83401bf622
commit 522f20702d
No known key found for this signature in database
GPG key ID: 26DA56488D314D11

View file

@ -13,15 +13,14 @@ public class YamlUtils {
}
private static void addDefaults(MemorySection defaults, YamlConfiguration yml, String root) {
MemorySection section = (MemorySection) defaults.get(root);
if (section == null) return;
for (String key : section.getKeys(false)) {
if (defaults == null) return;
for (String key : defaults.getKeys(false)) {
String newKey = (root.isEmpty() ? "" : root + ".") + key;
Object value = defaults.get(key);
if (value instanceof MemorySection) {
addDefaults((MemorySection) value, yml, newKey);
} else if (yml.get(key) == null) {
yml.set(key, value);
} else if (yml.get(newKey) == null) {
yml.set(newKey, value);
}
}
}