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. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 4e468cb7ccf683b8fc9e04a48cfc25779775e25f..211251fe7cd08074c040df2f4642f37d5f90d856 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -905,7 +905,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Paper try { BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); @@ -268,6 +270,14 @@ public class GameProfileCache { } catch (IOException ioexception) { ; } + // Paper start + }; + if (asyncSave) { + MCUtil.scheduleAsyncTask(save); + } else { + save.run(); + } + // Paper end }