From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 16 May 2016 20:47:41 -0400 Subject: [PATCH] Optimize UserCache / Thread Safe Because Techable keeps complaining about how this isn't thread safe, easier to do this than replace the entire thing. Additionally, move Saving of the User cache to be done async, incase the user never changed the default setting for Spigot's save on stop only. 1.17: TODO does this need the synchronized blocks anymore? diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 45bcdf2e644999910784432d8f369e775ce6506d..3e2955013ce75034170b5eeae60482e1c174769d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -964,7 +964,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Paper try { BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); @@ -305,6 +306,14 @@ public class GameProfileCache { } catch (IOException ioexception) { ; } + // Paper start + }; + if (asyncSave) { + net.minecraft.server.MCUtil.scheduleAsyncTask(save); + } else { + save.run(); + } + // Paper end }