Fix #5688 config values are unordered, update Night-Config

This commit is contained in:
tterrag 2019-04-16 00:08:19 -04:00
parent c0aa4c8517
commit f30d7bc845
3 changed files with 5 additions and 3 deletions

View file

@ -294,8 +294,8 @@ project(':forge') {
installer 'net.minecraftforge:forgespi:0.11.+' installer 'net.minecraftforge:forgespi:0.11.+'
installer 'net.minecraftforge:coremods:0.4.+' installer 'net.minecraftforge:coremods:0.4.+'
installer 'net.minecraftforge:unsafe:0.2.+' installer 'net.minecraftforge:unsafe:0.2.+'
installer 'com.electronwill.night-config:core:3.5.0' installer 'com.electronwill.night-config:core:3.6.0'
installer 'com.electronwill.night-config:toml:3.5.0' installer 'com.electronwill.night-config:toml:3.6.0'
installer 'org.jline:jline:3.9.0' installer 'org.jline:jline:3.9.0'
installer 'org.apache.maven:maven-artifact:3.6.0' installer 'org.apache.maven:maven-artifact:3.6.0'
installer 'net.jodah:typetools:0.6.0' installer 'net.jodah:typetools:0.6.0'

View file

@ -30,6 +30,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -193,7 +194,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<Config>
public static class Builder 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 BuilderContext context = new BuilderContext();
private Map<List<String>, String> levelComments = new HashMap<>(); private Map<List<String>, String> levelComments = new HashMap<>();
private List<String> currentPath = new ArrayList<>(); private List<String> currentPath = new ArrayList<>();

View file

@ -39,6 +39,7 @@ public class ConfigFileTypeHandler {
return (c) -> { return (c) -> {
final Path configPath = configBasePath.resolve(c.getFileName()); final Path configPath = configBasePath.resolve(c.getFileName());
final CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync(). final CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync().
preserveInsertionOrder().
autosave(). autosave().
writingMode(WritingMode.REPLACE). writingMode(WritingMode.REPLACE).
build(); build();