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/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java index aade5e291b80c5362c8fd8cf09faca8e631e0554..2d74d14385c7e705cb210bcfc0780f4c9c6a1cda 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -210,7 +210,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } if (this.convertNames()) { - this.getUserCache().b(); + this.getUserCache().b(false); // Paper } if (!NameReferencingFileConverter.e(this)) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 165e915c9c76b603b61d0548a85ec8e09f25ca05..9dd54bea5f9a7d1cb638100312855135f83bcaf9 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -786,7 +786,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant { // Paper try { BufferedWriter bufferedwriter = Files.newWriter(this.g, StandardCharsets.UTF_8); @@ -266,6 +267,14 @@ public class UserCache { } catch (IOException ioexception) { ; } + // Paper start + }; + if (asyncSave) { + MCUtil.scheduleAsyncTask(save); + } else { + save.run(); + } + // Paper end }