From 6293cc8c27381c9900c48a6ab35b02215a9c0d50 Mon Sep 17 00:00:00 2001 From: s809 <43530948+s809@users.noreply.github.com> Date: Thu, 5 Sep 2024 14:22:00 +0500 Subject: [PATCH] Prefill levelKeyPrefix in new worlds --- .../com/seibel/distanthorizons/core/config/Config.java | 7 ++++++- .../minecraft/IMinecraftSharedWrapper.java | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index 4c24da923..45621b4eb 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -43,6 +43,7 @@ import javax.swing.*; import java.awt.*; import java.util.*; import java.util.List; +import java.util.concurrent.ThreadLocalRandom; /** @@ -1019,7 +1020,11 @@ public class Config public static ConfigEntry levelKeyPrefix = new ConfigEntry.Builder() .setServersideShortName("levelKeyPrefix") .setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) - .set("") + .set( + SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class).isWorldInitialized() + ? "" + : "server" + ThreadLocalRandom.current().nextInt(1, 1000) + ) .comment("" + "Prefix of the level keys sent to the clients.\n" + "Should be set to a unique value for each backend server behind a proxy,\n" diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftSharedWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftSharedWrapper.java index 95bc31714..1b1b84dd9 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftSharedWrapper.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftSharedWrapper.java @@ -30,4 +30,6 @@ public interface IMinecraftSharedWrapper extends IBindable File getInstallationDirectory(); + boolean isWorldInitialized(); + } \ No newline at end of file