SPIGOT-4558: Preserve user order in the face of copied defaults in configurations

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2018-12-31 17:10:56 +11:00
parent 1c116bb13c
commit 6a8d62ff22
2 changed files with 13 additions and 5 deletions

View File

@@ -742,7 +742,12 @@ public class MemorySection implements ConfigurationSection {
MemorySection sec = (MemorySection) section;
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
output.put(createPath(section, entry.getKey(), this), entry.getValue());
// Because of the copyDefaults call potentially copying out of order, we must remove and then add in our saved order
// This means that default values we haven't set end up getting placed first
// See SPIGOT-4558 for an example using spigot.yml - watch subsections move around to default order
String childPath = createPath(section, entry.getKey(), this);
output.remove(childPath);
output.put(childPath, entry.getValue());
if (entry.getValue() instanceof ConfigurationSection) {
if (deep) {