diff options
author | Owen <[email protected]> | 2023-02-19 09:57:10 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2023-02-19 08:57:10 -0600 |
commit | 841da90501564e5b430a8469cac6e6a77627725d (patch) | |
tree | 934f58b2dfbf689e502651e4a3ad51383779f4c0 /patches/server/0098-Async-GameProfileCache-saving.patch | |
parent | f9dc371fd8c56f1ad1359fc3bf1f7a40921ec66f (diff) | |
download | Paper-841da90501564e5b430a8469cac6e6a77627725d.tar.gz Paper-841da90501564e5b430a8469cac6e6a77627725d.zip |
Paper Plugins (#8108)
Diffstat (limited to 'patches/server/0098-Async-GameProfileCache-saving.patch')
-rw-r--r-- | patches/server/0098-Async-GameProfileCache-saving.patch | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/patches/server/0098-Async-GameProfileCache-saving.patch b/patches/server/0098-Async-GameProfileCache-saving.patch new file mode 100644 index 0000000000..f7d915bad3 --- /dev/null +++ b/patches/server/0098-Async-GameProfileCache-saving.patch @@ -0,0 +1,86 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Mon, 16 May 2016 20:47:41 -0400 +Subject: [PATCH] Async GameProfileCache saving + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 3ed50490121f34ab5b247565b9a4555bf6a46dff..0a419ec121bbddffa0424147c642f79d4e5eb817 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -934,7 +934,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa + } catch (java.lang.InterruptedException ignored) {} // Paper + if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { + MinecraftServer.LOGGER.info("Saving usercache.json"); +- this.getProfileCache().save(); ++ this.getProfileCache().save(false); // Paper + } + // Spigot end + io.papermc.paper.chunk.system.io.RegionFileIOThread.close(true); // Paper // Paper - rewrite chunk system +diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +index 18f7d73fd8a780753e2249a9fec6bb335ebfdeed..35904c69e14c4c0addda204d5e3788518c2e16c4 100644 +--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +@@ -242,7 +242,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + } + + if (this.convertOldUsers()) { +- this.getProfileCache().save(); ++ this.getProfileCache().save(false); // Paper + } + + if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { +diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java +index d246563021c32127e570809f4d849b6a156f4dc6..225e15d686675e21969c4210fa38fef58d920355 100644 +--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java ++++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java +@@ -127,7 +127,7 @@ public class GameProfileCache { + GameProfileCache.GameProfileInfo usercache_usercacheentry = new GameProfileCache.GameProfileInfo(profile, date); + + this.safeAdd(usercache_usercacheentry); +- if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(); // Spigot - skip saving if disabled ++ if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(true); // Spigot - skip saving if disabled // Paper - async + } + + private long getNextOperation() { +@@ -160,7 +160,7 @@ public class GameProfileCache { + } + + if (flag && !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { // Spigot - skip saving if disabled +- this.save(); ++ this.save(true); // Paper + } + + return optional; +@@ -274,7 +274,7 @@ public class GameProfileCache { + return arraylist; + } + +- public void save() { ++ public void save(boolean asyncSave) { // Paper + JsonArray jsonarray = new JsonArray(); + DateFormat dateformat = GameProfileCache.createDateFormat(); + +@@ -282,6 +282,7 @@ public class GameProfileCache { + jsonarray.add(GameProfileCache.writeGameProfile(usercache_usercacheentry, dateformat)); + }); + String s = this.gson.toJson(jsonarray); ++ Runnable save = () -> { // Paper + + try { + BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); +@@ -306,6 +307,14 @@ public class GameProfileCache { + } catch (IOException ioexception) { + ; + } ++ // Paper start ++ }; ++ if (asyncSave) { ++ io.papermc.paper.util.MCUtil.scheduleAsyncTask(save); ++ } else { ++ save.run(); ++ } ++ // Paper end + + } + |