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 f990f242a8d812a93b454b065a17fd4e8170355a..283c1111d99b6ae09b6db0c0079eeb0f1cbb7b2b 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -907,7 +907,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant { // Paper try { BufferedWriter bufferedwriter = Files.newWriter(this.g, StandardCharsets.UTF_8); @@ -268,6 +270,14 @@ public class UserCache { } catch (IOException ioexception) { ; } + // Paper start + }; + if (asyncSave) { + MCUtil.scheduleAsyncTask(save); + } else { + save.run(); + } + // Paper end }