From e788a93e175c7f0c50f2805884260c74f978e531 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Thu, 5 Jun 2025 02:48:13 +0800 Subject: [PATCH] Fix --- .../0048-Cache-player-profileResult.patch | 28 ++++++------------- ...0054-Configurable-connection-message.patch | 6 ++-- ...t-place-player-if-the-server-is-full.patch | 4 +-- .../0100-Smooth-teleport-config.patch | 4 +-- ...-SparklyPaper-Parallel-world-ticking.patch | 6 ++-- .../0165-Async-switch-connection-state.patch | 4 +-- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/leaf-server/minecraft-patches/features/0048-Cache-player-profileResult.patch b/leaf-server/minecraft-patches/features/0048-Cache-player-profileResult.patch index aa59e724..36ccec15 100644 --- a/leaf-server/minecraft-patches/features/0048-Cache-player-profileResult.patch +++ b/leaf-server/minecraft-patches/features/0048-Cache-player-profileResult.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Cache player profileResult diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40ec4e1124 100644 +index 069477e524a28b20a0289221858bdc802704a890..114b25f933c6a1b011523581a5a02a5a2c1e827e 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -71,6 +71,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -71,6 +71,14 @@ 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 @@ -16,12 +16,14 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40 + private static final com.github.benmanes.caffeine.cache.Cache playerProfileResultCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder() + .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES) + .build(); -+ public static final java.util.Map playerSession = new java.util.concurrent.ConcurrentHashMap<>(); ++ private static final com.github.benmanes.caffeine.cache.Cache playerSession = 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; -@@ -304,9 +310,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -304,9 +312,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); try { @@ -34,14 +36,14 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40 + profileResult = playerProfileResultCache.getIfPresent(string1); + + InetAddress address = this.getAddress(); -+ InetAddress lastAddress = playerSession.get(string1); ++ InetAddress lastAddress = playerSession.getIfPresent(string1); + if (isInvalidSession(address, lastAddress)) { + // Send request to mojang server to verify session + // Result will be null if is invalid and will do disconnect logic below + profileResult = ServerLoginPacketListenerImpl.this.server + .getSessionService() + .hasJoinedServer(string1, string, address); -+ if (profileResult != null) { ++ if (profileResult != null && address != null) { + playerProfileResultCache.put(string1, profileResult); + playerSession.put(string1, address); + } @@ -55,7 +57,7 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40 if (profileResult != null) { GameProfile gameProfile = profileResult.profile(); // CraftBukkit start - fire PlayerPreLoginEvent -@@ -351,6 +378,20 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -351,6 +380,20 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, // Paper end - Cache authenticator threads } @@ -76,15 +78,3 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40 // CraftBukkit start private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent // Paper start - Add Velocity IP Forwarding Support -diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index e8683f45823cac55e3e68ccc500f10f0632e72fd..f71debc88c1d16c09546c026817aa192faac8fc6 100644 ---- a/net/minecraft/server/players/PlayerList.java -+++ b/net/minecraft/server/players/PlayerList.java -@@ -669,6 +669,7 @@ public abstract class PlayerList { - // Paper end - Fix kick event leave message not being sent - org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar - net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(player.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system -+ net.minecraft.server.network.ServerLoginPacketListenerImpl.playerSession.remove(player.getBukkitEntity().getName()); // Leaf - Cache player profileResult - ServerLevel serverLevel = player.serverLevel(); - player.awardStat(Stats.LEAVE_GAME); - // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it diff --git a/leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch b/leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch index e16f7d4a..529a69d4 100644 --- a/leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch +++ b/leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable connection message diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index f71debc88c1d16c09546c026817aa192faac8fc6..4fa7952c30408e898cc2e3ce41d5b0f44f19ae31 100644 +index e8683f45823cac55e3e68ccc500f10f0632e72fd..5c88d51920481235145bb7fd8cf148607b2dbed0 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -434,7 +434,7 @@ public abstract class PlayerList { @@ -26,7 +26,7 @@ index f71debc88c1d16c09546c026817aa192faac8fc6..4fa7952c30408e898cc2e3ce41d5b0f4 joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure } -@@ -678,7 +678,7 @@ public abstract class PlayerList { +@@ -677,7 +677,7 @@ public abstract class PlayerList { player.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason } @@ -35,7 +35,7 @@ index f71debc88c1d16c09546c026817aa192faac8fc6..4fa7952c30408e898cc2e3ce41d5b0f4 this.cserver.getPluginManager().callEvent(playerQuitEvent); player.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); -@@ -1674,4 +1674,38 @@ public abstract class PlayerList { +@@ -1673,4 +1673,38 @@ public abstract class PlayerList { public boolean isAllowCommandsForAllPlayers() { return this.allowCommandsForAllPlayers; } diff --git a/leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch b/leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch index ea9b96af..1edfcc4f 100644 --- a/leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch +++ b/leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Do not place player if the server is full Fix https://github.com/PaperMC/Paper/issues/10668 diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 4fa7952c30408e898cc2e3ce41d5b0f44f19ae31..6be59ddf2584455de0955b34d8ba1a053103f684 100644 +index 5c88d51920481235145bb7fd8cf148607b2dbed0..75fb49f1596f475278d12c8c7aea9ad4952b6056 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -341,6 +341,13 @@ public abstract class PlayerList { @@ -23,7 +23,7 @@ index 4fa7952c30408e898cc2e3ce41d5b0f44f19ae31..6be59ddf2584455de0955b34d8ba1a05 org.bukkit.Location loc = ev.getSpawnLocation(); serverLevel = ((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle(); -@@ -836,7 +843,7 @@ public abstract class PlayerList { +@@ -835,7 +842,7 @@ public abstract class PlayerList { // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile) // ? Component.translatable("multiplayer.disconnect.server_full") // : null; diff --git a/leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch b/leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch index 7e86b89e..aef1c4e6 100644 --- a/leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch +++ b/leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch @@ -30,10 +30,10 @@ index 4f01b53bf801f99253efd27df6216912705d18af..82a1715fea41e6a41c4ff441ea89f424 level.addDuringTeleport(this); this.triggerDimensionChangeTriggers(serverLevel); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 6be59ddf2584455de0955b34d8ba1a053103f684..66cb015de63949ca5add9dc3456db9c638b78048 100644 +index 75fb49f1596f475278d12c8c7aea9ad4952b6056..b17c8a2f5294ac28cc05fb05c84a041b2c6c8721 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -956,11 +956,11 @@ public abstract class PlayerList { +@@ -955,11 +955,11 @@ public abstract class PlayerList { byte b = (byte)(keepInventory ? 1 : 0); ServerLevel serverLevel = serverPlayer.serverLevel(); LevelData levelData = serverLevel.getLevelData(); diff --git a/leaf-server/minecraft-patches/features/0134-SparklyPaper-Parallel-world-ticking.patch b/leaf-server/minecraft-patches/features/0134-SparklyPaper-Parallel-world-ticking.patch index 5e1160e4..2b087735 100644 --- a/leaf-server/minecraft-patches/features/0134-SparklyPaper-Parallel-world-ticking.patch +++ b/leaf-server/minecraft-patches/features/0134-SparklyPaper-Parallel-world-ticking.patch @@ -867,7 +867,7 @@ index 8362def0dc61496a087bd859052bd80ebba83185..09f517059aa47ca67329bc913243d4fd // Paper end - Inventory close reason this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 66cb015de63949ca5add9dc3456db9c638b78048..1009421bfd289734b50a528bfca8d957e4610159 100644 +index b17c8a2f5294ac28cc05fb05c84a041b2c6c8721..3591de34443069f3f163f8d17df6372c3068611d 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -252,6 +252,8 @@ public abstract class PlayerList { @@ -879,7 +879,7 @@ index 66cb015de63949ca5add9dc3456db9c638b78048..1009421bfd289734b50a528bfca8d957 player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed GameProfile gameProfile = player.getGameProfile(); -@@ -892,6 +894,15 @@ public abstract class PlayerList { +@@ -891,6 +893,15 @@ public abstract class PlayerList { return this.respawn(player, keepInventory, reason, eventReason, null); } public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, org.bukkit.Location location) { @@ -895,7 +895,7 @@ index 66cb015de63949ca5add9dc3456db9c638b78048..1009421bfd289734b50a528bfca8d957 player.stopRiding(); // CraftBukkit this.players.remove(player); this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -903,6 +914,7 @@ public abstract class PlayerList { +@@ -902,6 +913,7 @@ public abstract class PlayerList { ServerPlayer serverPlayer = player; Level fromWorld = player.level(); player.wonGame = false; diff --git a/leaf-server/minecraft-patches/features/0165-Async-switch-connection-state.patch b/leaf-server/minecraft-patches/features/0165-Async-switch-connection-state.patch index 80676c50..7b06eff0 100644 --- a/leaf-server/minecraft-patches/features/0165-Async-switch-connection-state.patch +++ b/leaf-server/minecraft-patches/features/0165-Async-switch-connection-state.patch @@ -118,10 +118,10 @@ index 2e9eb04c7c4342393c05339906c267bca9ff29b1..53b9daa909c2b89046d5af515e17afe0 try { PlayerList playerList = this.server.getPlayerList(); diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index c25f5b92b16f45b960d9b405b2fe1c40ec4e1124..005fee891cdabc7105033be051389557631fb6d2 100644 +index 114b25f933c6a1b011523581a5a02a5a2c1e827e..5907f1c75002be5e2ef1f9875974e665f964db7a 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -492,11 +492,31 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -494,11 +494,31 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); }