Fire kick event for out-of-order chat on main thread (#7942)

This commit is contained in:
Jake Potrebic 2022-06-11 18:11:18 -07:00 committed by GitHub
parent 6c52b5e2c8
commit ee4916df7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 9 deletions

View File

@ -1,11 +1,13 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <jahnke.nassim@gmail.com>
Date: Mon, 17 Jan 2022 19:47:19 +0100
Subject: [PATCH] Kick on main for illegal chars
Subject: [PATCH] Kick on main for illegal chat
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 5927035f616f341f1d28b569efaf7812e4aa6880..6a83e098ebbf9ccde9c0726981393a376d99ab34 100644
index a84ab1754ffee0436ac3abf05e3fd69f3523e5e6..dbd16fabc781a2820dc073154830667ea88cb27d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2105,7 +2105,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@ -28,3 +30,13 @@ index 5927035f616f341f1d28b569efaf7812e4aa6880..6a83e098ebbf9ccde9c0726981393a37
} else {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (this.tryHandleChat(packet.command(), packet.timeStamp())) {
@@ -2145,7 +2149,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
private boolean tryHandleChat(String s, Instant instant) {
if (!this.updateChatOrder(instant)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), s);
+ this.server.scheduleOnMain(() -> { // Paper - push to main
this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"));
+ }); // Paper - push to main
return false;
} else {
if (this.isChatExpired(instant)) {

View File

@ -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 3c3b2530faa3f4b1da21d2e1f383706a64db1d01..01d634fc6ec59e97b7a35b243044f0e7a677dc8c 100644
index 842a1535e26afc6bc072f49d033479395de59a09..d8985815a947fd7007f87db8ebd2a6296899bee6 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3174,7 +3174,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -3176,7 +3176,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);

View File

@ -18,10 +18,10 @@ index 83cc8db3ca76898f88a56c27c2b6fde6006723ba..aea18838a17fc52e1bf8cd84cd185565
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 01d634fc6ec59e97b7a35b243044f0e7a677dc8c..0b74c52a2b138862335013846277064e6ad00047 100644
index d8985815a947fd7007f87db8ebd2a6296899bee6..736444c288421db84ae127d7b8cb746b6edc355f 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2783,7 +2783,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -2785,7 +2785,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
this.player = this.server.getPlayerList().respawn(this.player, false);
if (this.server.isHardcore()) {
this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper
@ -158,7 +158,7 @@ index 3c93bfeb94168f832904a8462ae23b06e81e080d..468c635d31cfa8051666bbefce8df4b4
this.onChanged(server);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 998ad03f4daa9f3b6d3dd70c5c912bc935ffd12f..9175fa06419ac726c4508f38ae3d454451fbb380 100644
index aa43f8fb00432ab96e459c19cc82c4b99fd2f33e..25e56be9055c5c432e1180d45341f4e9d9fcb7ca 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1914,7 +1914,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {

View File

@ -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 0b74c52a2b138862335013846277064e6ad00047..a9193fcd719e403e4b821a2a0cf22fe2a8490943 100644
index 736444c288421db84ae127d7b8cb746b6edc355f..a82f5516274c2e7b582d38c70cd116d23d0687c8 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3352,6 +3352,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -3354,6 +3354,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@Override
public void handleClientInformation(ServerboundClientInformationPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());