mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
50 lines
3.2 KiB
Diff
50 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Thu, 28 Mar 2024 13:36:09 -0400
|
|
Subject: [PATCH] Cache player profileResult
|
|
|
|
|
|
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
index b6f44bff24f48419a3a0157bb0ade9aa7c21e35e..b049304a80dc29c3087cff56c45c2c83679e47ff 100644
|
|
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -71,6 +71,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
private net.minecraft.server.level.ServerPlayer player; // CraftBukkit
|
|
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
|
private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
|
+ // Leaf start - Cache player profileResult
|
|
+ private static final com.github.benmanes.caffeine.cache.Cache<String, ProfileResult> playerProfileResultCahce = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
|
|
+ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES)
|
|
+ .build();
|
|
+ // Leaf end - Cache player profileResult
|
|
|
|
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
|
this.server = server;
|
|
@@ -302,9 +307,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());
|
|
+ // Leaf start - Cache player profileResult
|
|
+ ProfileResult profileResult;
|
|
+ if (org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResult) {
|
|
+ profileResult = playerProfileResultCahce.getIfPresent(string1);
|
|
+
|
|
+ if (profileResult == null) {
|
|
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
|
+ .getSessionService()
|
|
+ .hasJoinedServer(string1, string, this.getAddress());
|
|
+ playerProfileResultCahce.put(string1, profileResult);
|
|
+ }
|
|
+ } else {
|
|
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
|
+ .getSessionService()
|
|
+ .hasJoinedServer(string1, string, this.getAddress());
|
|
+ }
|
|
+ // Leaf end - Cache player profileResult
|
|
if (profileResult != null) {
|
|
GameProfile gameProfile = profileResult.profile();
|
|
// CraftBukkit start - fire PlayerPreLoginEvent
|