Fix defaults not being added properly
This commit is contained in:
parent
83401bf622
commit
522f20702d
1 changed files with 4 additions and 5 deletions
|
|
@ -13,15 +13,14 @@ public class YamlUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addDefaults(MemorySection defaults, YamlConfiguration yml, String root) {
|
private static void addDefaults(MemorySection defaults, YamlConfiguration yml, String root) {
|
||||||
MemorySection section = (MemorySection) defaults.get(root);
|
if (defaults == null) return;
|
||||||
if (section == null) return;
|
for (String key : defaults.getKeys(false)) {
|
||||||
for (String key : section.getKeys(false)) {
|
|
||||||
String newKey = (root.isEmpty() ? "" : root + ".") + key;
|
String newKey = (root.isEmpty() ? "" : root + ".") + key;
|
||||||
Object value = defaults.get(key);
|
Object value = defaults.get(key);
|
||||||
if (value instanceof MemorySection) {
|
if (value instanceof MemorySection) {
|
||||||
addDefaults((MemorySection) value, yml, newKey);
|
addDefaults((MemorySection) value, yml, newKey);
|
||||||
} else if (yml.get(key) == null) {
|
} else if (yml.get(newKey) == null) {
|
||||||
yml.set(key, value);
|
yml.set(newKey, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue