From 813d0399f9880c4ee5ccd3e60d9e20b358b70df2 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 6 May 2023 17:10:22 +0200 Subject: [PATCH] Make sure the player didn't disconnect when processing commands --- .../server/0783-Kick-on-main-for-illegal-chat.patch | 12 +++++++++--- ...5-Prevent-tile-entity-copies-loading-chunks.patch | 4 ++-- ...828-Pass-ServerLevel-for-gamerule-callbacks.patch | 4 ++-- .../0839-Do-not-accept-invalid-client-settings.patch | 4 ++-- ...minimal-debug-information-to-chat-packet-er.patch | 4 ++-- ...t-Config-not-using-commands.spam-exclusions.patch | 4 ++-- ...2-Remove-invalid-signature-login-stacktrace.patch | 4 ++-- patches/server/0928-Properly-resend-entities.patch | 4 ++-- ...-Add-missing-SpigotConfig-logCommands-check.patch | 4 ++-- ...se-single-player-info-update-packet-on-join.patch | 4 ++-- ...ausing-expired-keys-from-impacting-new-join.patch | 4 ++-- ...=> 0978-Fix-DamageCause-for-Falling-Blocks.patch} | 0 12 files changed, 29 insertions(+), 23 deletions(-) rename patches/server/{0977-Fix-DamageCause-for-Falling-Blocks.patch => 0978-Fix-DamageCause-for-Falling-Blocks.patch} (100%) diff --git a/patches/server/0783-Kick-on-main-for-illegal-chat.patch b/patches/server/0783-Kick-on-main-for-illegal-chat.patch index d79999e460..7c2d916a87 100644 --- a/patches/server/0783-Kick-on-main-for-illegal-chat.patch +++ b/patches/server/0783-Kick-on-main-for-illegal-chat.patch @@ -7,7 +7,7 @@ Makes the PlayerKickEvent fire on the main thread for illegal characters or chat out-of-order errors. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 8552f230b4ec64a6e056198d3edb04395138608a..1371ffc0426ff019c47f30f2cdeea51f72b137c3 100644 +index 8552f230b4ec64a6e056198d3edb04395138608a..c3d4a3d109746866bbade09e0c95d7897c912b4b 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2162,7 +2162,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -20,7 +20,7 @@ index 8552f230b4ec64a6e056198d3edb04395138608a..1371ffc0426ff019c47f30f2cdeea51f } else { Optional optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages()); -@@ -2196,7 +2198,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2196,12 +2198,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @Override public void handleChatCommand(ServerboundChatCommandPacket packet) { if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.command())) { @@ -30,7 +30,13 @@ index 8552f230b4ec64a6e056198d3edb04395138608a..1371ffc0426ff019c47f30f2cdeea51f } else { Optional optional = this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages()); -@@ -2276,7 +2280,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + if (optional.isPresent()) { + this.server.submit(() -> { ++ if (player.hasDisconnected()) return; // Paper + this.performChatCommand(packet, (LastSeenMessages) optional.get()); + this.detectRateSpam("/" + packet.command()); // Spigot + }); +@@ -2276,7 +2281,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic private Optional tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) { if (!this.updateChatOrder(timestamp)) { ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message); diff --git a/patches/server/0825-Prevent-tile-entity-copies-loading-chunks.patch b/patches/server/0825-Prevent-tile-entity-copies-loading-chunks.patch index f8e2712844..48ac8c2020 100644 --- a/patches/server/0825-Prevent-tile-entity-copies-loading-chunks.patch +++ b/patches/server/0825-Prevent-tile-entity-copies-loading-chunks.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Prevent tile entity copies loading chunks diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index bec15299c3421e800465120607d4da1e42787aa7..1c0d3f032b5abc4b1e99555105258376fed1f541 100644 +index f1155e7df523d2030c3fe9b488a77fae5ad2febd..fd6d2add5d6ecaab8824c90c4cf82254aeee37b6 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3302,7 +3302,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3303,7 +3303,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound); if (this.player.level.isLoaded(blockposition)) { diff --git a/patches/server/0828-Pass-ServerLevel-for-gamerule-callbacks.patch b/patches/server/0828-Pass-ServerLevel-for-gamerule-callbacks.patch index 55df7c7619..daea405f74 100644 --- a/patches/server/0828-Pass-ServerLevel-for-gamerule-callbacks.patch +++ b/patches/server/0828-Pass-ServerLevel-for-gamerule-callbacks.patch @@ -18,10 +18,10 @@ index 5b46cabf4f2e2a1f7feaad378dd98d64aeef8671..51b3db0b6c2cede95b584268e035c0fb if (dedicatedserverproperties.enableQuery) { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 1c0d3f032b5abc4b1e99555105258376fed1f541..aa70da970602d9c5e076b5036c296d6a9174e2bf 100644 +index fd6d2add5d6ecaab8824c90c4cf82254aeee37b6..709a0adbb4f869f6e5016ddd009aecfb428228fd 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2893,7 +2893,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2894,7 +2894,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH); if (this.server.isHardcore()) { this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper diff --git a/patches/server/0839-Do-not-accept-invalid-client-settings.patch b/patches/server/0839-Do-not-accept-invalid-client-settings.patch index 26d316c53a..d283217e2e 100644 --- a/patches/server/0839-Do-not-accept-invalid-client-settings.patch +++ b/patches/server/0839-Do-not-accept-invalid-client-settings.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Do not accept invalid client settings diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index aa70da970602d9c5e076b5036c296d6a9174e2bf..798eaaaed23c55728a7c48ea900db873cf5c5197 100644 +index 709a0adbb4f869f6e5016ddd009aecfb428228fd..9ff3af312429a0cd9479d85040b73b5c547c5367 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3481,6 +3481,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3482,6 +3482,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @Override public void handleClientInformation(ServerboundClientInformationPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); diff --git a/patches/server/0860-Add-some-minimal-debug-information-to-chat-packet-er.patch b/patches/server/0860-Add-some-minimal-debug-information-to-chat-packet-er.patch index 682114111a..9d37609ab7 100644 --- a/patches/server/0860-Add-some-minimal-debug-information-to-chat-packet-er.patch +++ b/patches/server/0860-Add-some-minimal-debug-information-to-chat-packet-er.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add some minimal debug information to chat packet errors TODO: potentially add some kick leeway diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 03ee980ae8fdaa174c937f1e5175020f0626556e..5b8e57196b810ac093e66718a3e4d987c5a8f1e3 100644 +index 5c85a9d609c02498a8f883bf44f5e85c21275318..05841b6e44396ed49618f5b478abe78fde0a73d0 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2285,7 +2285,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2286,7 +2286,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic private Optional tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) { if (!this.updateChatOrder(timestamp)) { diff --git a/patches/server/0862-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch b/patches/server/0862-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch index 90f332ccee..cd448ed276 100644 --- a/patches/server/0862-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch +++ b/patches/server/0862-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix Spigot Config not using commands.spam-exclusions diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 5b8e57196b810ac093e66718a3e4d987c5a8f1e3..dbc815053fc022cc62cd4fc418fecdf64a37a0a9 100644 +index 05841b6e44396ed49618f5b478abe78fde0a73d0..82d7506988b0e443bf16be93a9e17257aeff9472 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2532,7 +2532,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2533,7 +2533,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic } // Spigot end // this.chatSpamTickCount += 20; diff --git a/patches/server/0872-Remove-invalid-signature-login-stacktrace.patch b/patches/server/0872-Remove-invalid-signature-login-stacktrace.patch index 3c16aad292..10b7436b9e 100644 --- a/patches/server/0872-Remove-invalid-signature-login-stacktrace.patch +++ b/patches/server/0872-Remove-invalid-signature-login-stacktrace.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Remove invalid signature login stacktrace diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0909716c7b76bc07a2cd3caee4bede0a83255a06..b2a72e529b60eac033ac609cc11429ddbef0d422 100644 +index 0f6c2725ff7e9aa6bcef16658aefcbc586d979b5..959e8d2cfa195e28239da03464e45563fcdd1244 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3611,7 +3611,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3612,7 +3612,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator, Duration.ZERO)); } catch (ProfilePublicKey.ValidationException profilepublickey_b) { diff --git a/patches/server/0928-Properly-resend-entities.patch b/patches/server/0928-Properly-resend-entities.patch index 8cdf1fbd8d..14d88db8b2 100644 --- a/patches/server/0928-Properly-resend-entities.patch +++ b/patches/server/0928-Properly-resend-entities.patch @@ -66,10 +66,10 @@ index a276aed4821eb992e0f20e2d2c6229e0b96eef73..ff7ba7a161cfed7521354bc6e3f21ba0 public static class DataItem { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b2a72e529b60eac033ac609cc11429ddbef0d422..c3db04aefe288a42d6a82291cc0164c8b09e9afa 100644 +index 959e8d2cfa195e28239da03464e45563fcdd1244..e7d6e4354dc7e50716b902a54afd4cf2246dea62 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2791,7 +2791,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2792,7 +2792,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { diff --git a/patches/server/0939-Add-missing-SpigotConfig-logCommands-check.patch b/patches/server/0939-Add-missing-SpigotConfig-logCommands-check.patch index 1618b3c6a7..e817bbb65e 100644 --- a/patches/server/0939-Add-missing-SpigotConfig-logCommands-check.patch +++ b/patches/server/0939-Add-missing-SpigotConfig-logCommands-check.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add missing SpigotConfig logCommands check diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c3db04aefe288a42d6a82291cc0164c8b09e9afa..9029be5f8a1f2c0719bf5e4012f72b52cf82b060 100644 +index e7d6e4354dc7e50716b902a54afd4cf2246dea62..78f5ec6e2f7994fa3fded16c9745c1e6a3f7b8ea 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2249,7 +2249,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2250,7 +2250,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic private void performChatCommand(ServerboundChatCommandPacket packet, LastSeenMessages lastSeenMessages) { // CraftBukkit start String command = "/" + packet.command(); diff --git a/patches/server/0945-Use-single-player-info-update-packet-on-join.patch b/patches/server/0945-Use-single-player-info-update-packet-on-join.patch index d1205601a2..9b7e0ab9d2 100644 --- a/patches/server/0945-Use-single-player-info-update-packet-on-join.patch +++ b/patches/server/0945-Use-single-player-info-update-packet-on-join.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use single player info update packet on join diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 9029be5f8a1f2c0719bf5e4012f72b52cf82b060..f5888a2216a017b0db24ff7bfe2fc8f41b149605 100644 +index 78f5ec6e2f7994fa3fded16c9745c1e6a3f7b8ea..0b907605b21ce04815643d2ce6d220880aa8f2cf 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3626,7 +3626,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3627,7 +3627,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID()); this.chatMessageChain.append((executor) -> { this.player.setChatSession(session); diff --git a/patches/server/0969-Prevent-causing-expired-keys-from-impacting-new-join.patch b/patches/server/0969-Prevent-causing-expired-keys-from-impacting-new-join.patch index 306a07be6e..280d14e6e1 100644 --- a/patches/server/0969-Prevent-causing-expired-keys-from-impacting-new-join.patch +++ b/patches/server/0969-Prevent-causing-expired-keys-from-impacting-new-join.patch @@ -24,7 +24,7 @@ index 23e0e6937e28f09271a4ec7c35e0076a576cf3d3..4aa8b483841028fbcc43f9ed47730881 UPDATE_GAME_MODE((serialized, buf) -> { serialized.gameMode = GameType.byId(buf.readVarInt()); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 8258764bafe5ad2d9aeaafd830aab3bb6617d2ff..9c5754ac3b00d3f0cb80ec83a2beefadee6d0a14 100644 +index dac73f994d416900ef3a3253e040225a805c827a..04a92f33f15d1696e38d38839651adf7d0462cac 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -295,6 +295,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -49,7 +49,7 @@ index 8258764bafe5ad2d9aeaafd830aab3bb6617d2ff..9c5754ac3b00d3f0cb80ec83a2beefad } public void resetPosition() { -@@ -3624,6 +3632,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3625,6 +3633,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic private void resetPlayerChatState(RemoteChatSession session) { this.chatSession = session; diff --git a/patches/server/0977-Fix-DamageCause-for-Falling-Blocks.patch b/patches/server/0978-Fix-DamageCause-for-Falling-Blocks.patch similarity index 100% rename from patches/server/0977-Fix-DamageCause-for-Falling-Blocks.patch rename to patches/server/0978-Fix-DamageCause-for-Falling-Blocks.patch