0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/spigot.git synced 2024-11-21 20:56:14 +00:00
spigot/CraftBukkit-Patches/0049-Configurable-save-on-stop-only-for-UserCache.patch
2024-10-23 02:15:00 +11:00

64 lines
2.5 KiB
Diff

From 7ba7e0842e9fd295f8cc48c1dac734d2dda1246c Mon Sep 17 00:00:00 2001
From: drXor <mcyoungsota@gmail.com>
Date: Fri, 23 May 2014 18:05:10 -0400
Subject: [PATCH] Configurable save-on-stop-only for UserCache
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a591f58043..a4f66fe502 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -987,6 +987,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
} catch (IOException ioexception1) {
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
}
+ // Spigot start
+ if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
+ LOGGER.info("Saving usercache.json");
+ this.getProfileCache().save();
+ }
+ // Spigot end
}
diff --git a/src/main/java/net/minecraft/server/players/UserCache.java b/src/main/java/net/minecraft/server/players/UserCache.java
index 2791f6659d..cc3da591e4 100644
--- a/src/main/java/net/minecraft/server/players/UserCache.java
+++ b/src/main/java/net/minecraft/server/players/UserCache.java
@@ -117,7 +117,7 @@ public class UserCache {
UserCache.UserCacheEntry usercache_usercacheentry = new UserCache.UserCacheEntry(gameprofile, date);
this.safeAdd(usercache_usercacheentry);
- this.save();
+ if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(); // Spigot - skip saving if disabled
}
private long getNextOperation() {
@@ -149,7 +149,7 @@ public class UserCache {
}
}
- if (flag) {
+ if (flag && !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { // Spigot - skip saving if disabled
this.save();
}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index d8cd8b47ae..6dfa89f6fa 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -320,4 +320,10 @@ public class SpigotConfig
{
userCacheCap = getInt( "settings.user-cache-size", 1000 );
}
+
+ public static boolean saveUserCacheOnStopOnly;
+ private static void saveUserCacheOnStopOnly()
+ {
+ saveUserCacheOnStopOnly = getBoolean( "settings.save-user-cache-on-stop-only", false );
+ }
}
--
2.47.0