diff --git a/paper-server/patches/sources/net/minecraft/server/Main.java.patch b/paper-server/patches/sources/net/minecraft/server/Main.java.patch index 52ce803c2c..1b4fa089d9 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -43,7 +43,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -90,50 +100,82 @@ +@@ -90,50 +100,91 @@ OptionSpec optionspec15 = optionparser.nonOptions(); try { @@ -125,8 +125,17 @@ - File file = new File((String) optionset.valueOf(optionspec9)); - Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file); - String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); -+ File file = (File) optionset.valueOf("universe"); // CraftBukkit -+ Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), file, optionset); // Paper - pass OptionSet to load paper config files; override authentication service ++ // Paper start - fix SPIGOT-5824 ++ File file; ++ File userCacheFile = new File(Services.USERID_CACHE_FILE); ++ if (optionset.has("universe")) { ++ file = (File) optionset.valueOf("universe"); // CraftBukkit ++ userCacheFile = new File(file, Services.USERID_CACHE_FILE); ++ } else { ++ file = new File(bukkitConfiguration.getString("settings.world-container", ".")); ++ } ++ // Paper end - fix SPIGOT-5824 ++ Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), file, userCacheFile, optionset); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container + // CraftBukkit start + String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath()); @@ -136,7 +145,7 @@ Dynamic dynamic; if (convertable_conversionsession.hasWorldData()) { -@@ -174,13 +216,31 @@ +@@ -174,13 +225,31 @@ } Dynamic dynamic1 = dynamic; @@ -169,7 +178,7 @@ WorldStem worldstem; -@@ -189,6 +249,7 @@ +@@ -189,6 +258,7 @@ worldstem = (WorldStem) Util.blockUntilDone((executor) -> { return WorldLoader.load(worldloader_c, (worldloader_a) -> { @@ -177,7 +186,7 @@ Registry iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); if (dynamic1 != null) { -@@ -201,7 +262,7 @@ +@@ -201,7 +271,7 @@ WorldOptions worldoptions; WorldDimensions worlddimensions; @@ -186,7 +195,7 @@ worldsettings = MinecraftServer.DEMO_SETTINGS; worldoptions = WorldOptions.DEMO_OPTIONS; worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen()); -@@ -209,7 +270,7 @@ +@@ -209,7 +279,7 @@ DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); worldsettings = new LevelSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration()); @@ -195,7 +204,7 @@ worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); } -@@ -225,32 +286,44 @@ +@@ -225,32 +295,44 @@ return; } @@ -245,7 +254,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.halt(true); -@@ -259,6 +332,7 @@ +@@ -259,6 +341,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -253,7 +262,7 @@ } catch (Exception exception1) { Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); } -@@ -295,7 +369,7 @@ +@@ -295,7 +378,7 @@ } public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier continueCheck, RegistryAccess dynamicRegistryManager, boolean recreateRegionFiles) { diff --git a/paper-server/patches/sources/net/minecraft/server/Services.java.patch b/paper-server/patches/sources/net/minecraft/server/Services.java.patch index e8ea9d1a00..c556957aab 100644 --- a/paper-server/patches/sources/net/minecraft/server/Services.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Services.java.patch @@ -9,24 +9,26 @@ - MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache + MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations // Paper - add paper configuration files ) { +- private static final String USERID_CACHE_FILE = "usercache.json"; + // Paper start - add paper configuration files + public Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) { + this(sessionService, servicesKeySet, profileRepository, profileCache, null); + } -+ + +- public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory) { + @Override + public io.papermc.paper.configuration.PaperConfigurations paperConfigurations() { + return java.util.Objects.requireNonNull(this.paperConfigurations); + } + // Paper end - add paper configuration files - private static final String USERID_CACHE_FILE = "usercache.json"; - -- public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory) { -+ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files ++ public static final String USERID_CACHE_FILE = "usercache.json"; // Paper - private -> public ++ ++ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files; add userCacheFile parameter MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService(); GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository(); - GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(rootDirectory, "usercache.json")); +- GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(rootDirectory, "usercache.json")); - return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache); ++ GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, userCacheFile); // Paper - use specified user cache file + // Paper start - load paper config files from cli options + final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath(); + final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath();