@@ -65,10 +65,10 @@ index 0000000000000000000000000000000000000000..817fd26cc3591f9cae0f61f4036dde43
65
65
+ }
66
66
diff --git a/src/main/java/io/papermc/paper/configuration/ConfigurationLoaders.java b/src/main/java/io/papermc/paper/configuration/ConfigurationLoaders.java
67
67
new file mode 100644
68
- index 0000000000000000000000000000000000000000..cb7d11dcf13c6ac464634a7e8115bf3dee0e72a2
68
+ index 0000000000000000000000000000000000000000..227039a6c69c4c99bbd9c674b3aab0ef5e2c1374
69
69
--- /dev/null
70
70
+++ b/src/main/java/io/papermc/paper/configuration/ConfigurationLoaders.java
71
- @@ -0,0 +1,26 @@
71
+ @@ -0,0 +1,27 @@
72
72
+ package io.papermc.paper.configuration;
73
73
+
74
74
+ import java.nio.file.Path;
@@ -85,6 +85,7 @@ index 0000000000000000000000000000000000000000..cb7d11dcf13c6ac464634a7e8115bf3d
85
85
+ return YamlConfigurationLoader.builder()
86
86
+ .indent(2)
87
87
+ .nodeStyle(NodeStyle.BLOCK)
88
+ + .headerMode(HeaderMode.PRESET)
88
89
+ .defaultOptions(options -> options.mapFactory(MapFactories.sortedNatural()));
89
90
+ }
90
91
+
@@ -896,10 +897,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
896
897
+ }
897
898
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
898
899
new file mode 100644
899
- index 0000000000000000000000000000000000000000..bc46e342b398dc56c976702d98ff3646995eb41e
900
+ index 0000000000000000000000000000000000000000..518a00886f7bde1de95150366541fc992f178246
900
901
--- /dev/null
901
902
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
902
- @@ -0,0 +1,396 @@
903
+ @@ -0,0 +1,405 @@
903
904
+ package io.papermc.paper.configuration;
904
905
+
905
906
+ import com.google.common.base.Suppliers;
@@ -963,6 +964,7 @@ index 0000000000000000000000000000000000000000..bc46e342b398dc56c976702d98ff3646
963
964
+ import java.util.HashMap;
964
965
+ import java.util.List;
965
966
+ import java.util.Map;
967
+ + import java.util.function.Function;
966
968
+ import java.util.function.Supplier;
967
969
+
968
970
+ import static com.google.common.base.Preconditions.checkState;
@@ -978,19 +980,20 @@ index 0000000000000000000000000000000000000000..bc46e342b398dc56c976702d98ff3646
978
980
+ public static final String CONFIG_DIR = "config";
979
981
+ private static final String BACKUP_DIR ="legacy-backup";
980
982
+
981
- + private static final String GLOBAL_HEADER = """
983
+ + private static final String GLOBAL_HEADER = String.format( """
982
984
+ This is the global configuration file for Paper.
983
985
+ As you can see, there's a lot to configure. Some options may impact gameplay, so use
984
986
+ with caution, and make sure you know what each option does before configuring.
985
987
+
986
988
+ If you need help with the configuration or have any questions related to Paper,
987
989
+ join us in our Discord or check the docs page.
988
990
+
989
- + The world configuration options have been moved to their own files.
991
+ + The world configuration options have been moved inside
992
+ + their respective world folder. The files are named %s
990
993
+
994
+ + Docs: https://docs.papermc.io/
991
995
+ Discord: https://discord.gg/papermc
992
- + Website: https://papermc.io/
993
- + Docs: https://docs.papermc.io/""";
996
+ + Website: https://papermc.io/""", WORLD_CONFIG_FILE_NAME);
994
997
+
995
998
+ private static final String WORLD_DEFAULTS_HEADER = """
996
999
+ This is the world defaults configuration file for Paper.
@@ -1003,13 +1006,20 @@ index 0000000000000000000000000000000000000000..bc46e342b398dc56c976702d98ff3646
1003
1006
+ Configuration options here apply to all worlds, unless you specify overrides inside
1004
1007
+ the world-specific config file inside each world folder.
1005
1008
+
1009
+ + Docs: https://docs.papermc.io/
1006
1010
+ Discord: https://discord.gg/papermc
1007
- + Website: https://papermc.io/
1008
- + Docs: https://docs.papermc.io/""";
1009
- +
1010
- + private static final String WORLD_HEADER = """
1011
- + This is a world configuration file for Paper.
1012
- + This file may start empty but can be filled with settings to override ones in the config/world-defaults.yml""";
1011
+ + Website: https://papermc.io/""";
1012
+ +
1013
+ + private static final Function<ContextMap, String> WORLD_HEADER = map -> String.format("""
1014
+ + This is a world configuration file for Paper.
1015
+ + This file may start empty but can be filled with settings to override ones in the %s/%s
1016
+ +
1017
+ + World: %s (%s)""",
1018
+ + PaperConfigurations.CONFIG_DIR,
1019
+ + PaperConfigurations.WORLD_DEFAULTS_CONFIG_FILE_NAME,
1020
+ + map.require(WORLD_NAME),
1021
+ + map.require(WORLD_KEY)
1022
+ + );
1013
1023
+
1014
1024
+ private static final Supplier<SpigotWorldConfig> SPIGOT_WORLD_DEFAULTS = Suppliers.memoize(() -> new SpigotWorldConfig(RandomStringUtils.randomAlphabetic(255)) {
1015
1025
+ @Override // override to ensure "verbose" is false
@@ -1084,7 +1094,7 @@ index 0000000000000000000000000000000000000000..bc46e342b398dc56c976702d98ff3646
1084
1094
+ protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) {
1085
1095
+ return super.createWorldConfigLoaderBuilder(contextMap)
1086
1096
+ .defaultOptions(options -> options
1087
- + .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER)
1097
+ + .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap) )
1088
1098
+ .serializers(serializers -> serializers
1089
1099
+ .register(new TypeToken<Reference2IntMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2IntMap<?>>(Reference2IntOpenHashMap::new, Integer.TYPE))
1090
1100
+ .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE))
0 commit comments