Prefill levelKeyPrefix in new worlds

This commit is contained in:
s809
2024-09-05 14:22:00 +05:00
parent 0361e5c69b
commit 6293cc8c27
2 changed files with 8 additions and 1 deletions
@@ -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<String> levelKeyPrefix = new ConfigEntry.Builder<String>()
.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"
@@ -30,4 +30,6 @@ public interface IMinecraftSharedWrapper extends IBindable
File getInstallationDirectory();
boolean isWorldInitialized();
}