From f30d7bc84573740422961dfa575d5dce47f3bd6e Mon Sep 17 00:00:00 2001 From: tterrag Date: Tue, 16 Apr 2019 00:08:19 -0400 Subject: [PATCH] Fix #5688 config values are unordered, update Night-Config --- build.gradle | 4 ++-- src/main/java/net/minecraftforge/common/ForgeConfigSpec.java | 3 ++- .../net/minecraftforge/fml/config/ConfigFileTypeHandler.java | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 8297caeb8..878398f6d 100644 --- a/build.gradle +++ b/build.gradle @@ -294,8 +294,8 @@ project(':forge') { installer 'net.minecraftforge:forgespi:0.11.+' installer 'net.minecraftforge:coremods:0.4.+' installer 'net.minecraftforge:unsafe:0.2.+' - installer 'com.electronwill.night-config:core:3.5.0' - installer 'com.electronwill.night-config:toml:3.5.0' + installer 'com.electronwill.night-config:core:3.6.0' + installer 'com.electronwill.night-config:toml:3.6.0' installer 'org.jline:jline:3.9.0' installer 'org.apache.maven:maven-artifact:3.6.0' installer 'net.jodah:typetools:0.6.0' diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index ddafe1aaa..c02f1c8b5 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -30,6 +30,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -193,7 +194,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper public static class Builder { - private final Config storage = InMemoryFormat.withUniversalSupport().createConfig(); + private final Config storage = Config.of(LinkedHashMap::new, InMemoryFormat.withUniversalSupport()); // Use LinkedHashMap for consistent ordering private BuilderContext context = new BuilderContext(); private Map, String> levelComments = new HashMap<>(); private List currentPath = new ArrayList<>(); diff --git a/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java b/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java index 3931d2a3c..2aeb67a2f 100644 --- a/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java +++ b/src/main/java/net/minecraftforge/fml/config/ConfigFileTypeHandler.java @@ -39,6 +39,7 @@ public class ConfigFileTypeHandler { return (c) -> { final Path configPath = configBasePath.resolve(c.getFileName()); final CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync(). + preserveInsertionOrder(). autosave(). writingMode(WritingMode.REPLACE). build();