Rework populator seed migration from tuinity config

This commit is contained in:
William Blake Galbreath
2021-06-28 01:51:00 -05:00
parent 0f3e9b0e9e
commit 99346c5689
2 changed files with 14 additions and 14 deletions

View File

@@ -39,7 +39,7 @@ index a7a7e6cd87270e64a92448f03f8b0b0c7e375ec7..9fb19162c0e436122087d03d37b502a1
try {
region.setCurrentlyGenerating(supplier3);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 6629addad421042fae15d1b70c0a8d51ecf5f3e2..9c766351673b66f02db3b88ef7b1651e63779307 100644
index 6629addad421042fae15d1b70c0a8d51ecf5f3e2..de47ddf70c993a1f8600062005eab6dd44475b56 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -2242,4 +2242,20 @@ public class PurpurWorldConfig {
@@ -49,17 +49,17 @@ index 6629addad421042fae15d1b70c0a8d51ecf5f3e2..9c766351673b66f02db3b88ef7b1651e
+
+ public boolean randomPopulatorSeed = false;
+ private void seedSettings() {
+ randomPopulatorSeed = getBoolean("seed.random-populator-seed", randomPopulatorSeed);
+ if (!randomPopulatorSeed) {
+ ConfigurationSection defaultTuinity = TuinityConfig.config.getConfigurationSection("world-settings.default");
+ ConfigurationSection currentTuinity = TuinityConfig.config.getConfigurationSection(level.tuinityConfig.configPath);
+ if (currentTuinity.getString("worldgen.seeds.populator", defaultTuinity.getString("worldgen.seeds.populator", "default")).equalsIgnoreCase("random")) {
+ randomPopulatorSeed = true;
+ if (PurpurConfig.version < 16) {
+ try {
+ java.lang.reflect.Method method = TuinityConfig.WorldConfig.class.getDeclaredMethod("getString", String.class, String.class);
+ method.setAccessible(true);
+ String def = (String) method.invoke(level.tuinityConfig, "worldgen.seeds.populator", "default");
+ if (def.equalsIgnoreCase("random")) {
+ set("seed.random-populator-seed", true);
+ }
+ } catch (NoSuchMethodException | java.lang.reflect.InvocationTargetException | IllegalAccessException ignore) {
+ }
+ defaultTuinity.set("worldgen.seeds.populator", null);
+ currentTuinity.set("worldgen.seeds.populator", null);
+ }
+
+ set("seed.random-populator-seed", randomPopulatorSeed);
+ randomPopulatorSeed = getBoolean("seed.random-populator-seed", randomPopulatorSeed);
+ }
}