Fix state locking for getTopMRUProfiles & getProfileIfCached

Also add missing last access update in getProfileIfCached
This commit is contained in:
Jason Penilla 2022-03-17 19:44:45 -07:00 committed by Jason
parent 2eeca6f108
commit 319d5fa29f
3 changed files with 50 additions and 15 deletions

View file

@ -599,17 +599,21 @@ index b49528d8a2c577def4f74ee694ffd53b481acb32..8f5784ed4df46f3c7d4c6b4ff76ad839
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
GameProfileCache usercache = new GameProfileCache(gameprofilerepository, new File(file, MinecraftServer.USERID_CACHE_FILE.getName()));
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
index c3e3a9950ee05dc97f15ab128e40854901f38a2f..95974d78196397136179f8d6acf1597c557e5a23 100644
index c3e3a9950ee05dc97f15ab128e40854901f38a2f..d7eba4190110b92641664c827c6bc50f62d2ae15 100644
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
@@ -135,6 +135,13 @@ public class GameProfileCache {
@@ -135,6 +135,17 @@ public class GameProfileCache {
return this.operationCount.incrementAndGet();
}
+ // Paper start
+ @Nullable public GameProfile getProfileIfCached(String name) {
+ GameProfileCache.GameProfileInfo entry = this.profilesByName.get(name.toLowerCase(Locale.ROOT));
+ return entry == null ? null : entry.getProfile();
+ if (entry == null) {
+ return null;
+ }
+ entry.setLastAccess(this.getNextOperation());
+ return entry.getProfile();
+ }
+ // Paper end
+