mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
50 lines
3.1 KiB
Diff
50 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sat, 26 Apr 2025 22:30:35 +0300
|
|
Subject: [PATCH] Player ProfileResult caching
|
|
|
|
|
|
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
index 10aecbb88a9a3dae3ecdf28aa449f1a1475a1905..13b468d4d3b92bf71fdfa112dfe56464c4f9dbed 100644
|
|
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -75,6 +75,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
public @Nullable java.util.UUID requestedUuid; // Paper
|
|
private final io.papermc.paper.connection.PaperPlayerLoginConnection paperLoginConnection; // Paper - Config API
|
|
private volatile boolean disconnecting = false; // Paper - Fix disconnect still ticking login
|
|
+ // DivineMC start - Player ProfileResult caching
|
|
+ private static final com.google.common.cache.Cache<String, ProfileResult> playerProfileResultCache = com.google.common.cache.CacheBuilder.newBuilder()
|
|
+ .expireAfterWrite(1, java.util.concurrent.TimeUnit.MINUTES)
|
|
+ .build();
|
|
+ // DivineMC end - Player ProfileResult caching
|
|
|
|
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
|
this.server = server;
|
|
@@ -260,9 +265,23 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized");
|
|
|
|
try {
|
|
- ProfileResult profileResult = ServerLoginPacketListenerImpl.this.server
|
|
- .getSessionService()
|
|
- .hasJoinedServer(string1, string, this.getAddress());
|
|
+ // DivineMC start - Player ProfileResult caching
|
|
+ ProfileResult profileResult;
|
|
+ if (org.bxteam.divinemc.config.DivineConfig.NetworkCategory.playerProfileResultCachingEnabled) {
|
|
+ profileResult = playerProfileResultCache.getIfPresent(string1);
|
|
+
|
|
+ if (profileResult == null) {
|
|
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
|
+ .getSessionService()
|
|
+ .hasJoinedServer(string1, string, this.getAddress());
|
|
+ playerProfileResultCache.put(string1, profileResult);
|
|
+ }
|
|
+ } else {
|
|
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
|
+ .getSessionService()
|
|
+ .hasJoinedServer(string1, string, this.getAddress());
|
|
+ }
|
|
+ // DivineMC end - Player ProfileResult caching
|
|
if (profileResult != null) {
|
|
GameProfile gameProfile = profileResult.profile();
|
|
// CraftBukkit start - fire PlayerPreLoginEvent
|