Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 19:40:07 +01:00
385f313a8b
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: d41796de SPIGOT-7071: Add Player#stopSound(SoundCategory category) 61dae5b2 SPIGOT-7011, SPIGOT-7065: Overhaul of structures CraftBukkit Changes: 991aeda12 SPIGOT-1729, SPIGOT-7090: Keep precision in teleportation between worlds 5c9a5f628 SPIGOT-7071: Add Player#stopSound(SoundCategory category) 68f888ded SPIGOT-7011, SPIGOT-7065: Overhaul of structures 0231a3746 Remove outdated build delay. Spigot Changes: 475f6008 Rebuild patches 8ce1761f Rebuild patches
101 Zeilen
5.4 KiB
Diff
101 Zeilen
5.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
|
Date: Wed, 8 Jun 2022 21:30:34 +0200
|
|
Subject: [PATCH] Untrash chat handling
|
|
|
|
Vanilla technically allows chat messages with starting slashes now,
|
|
Spigot still accepts them as commands, most likely due to being too
|
|
lazy to properly differentiate between chat and command intent in
|
|
their implementation. This disallows modified clients to send chat
|
|
messages with slashes and makes sure chat validation always happens
|
|
on the netty event loop, rather than there and possibly being moved
|
|
to the main thread, thus having the delayed handling cause a bad
|
|
process order of message ids.
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
|
index 3825aa2c381a3ee77e05bea520ff5fb828733857..4e9832d5753b98621e68246ffc5d80c86a3b5ed3 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
|
@@ -40,24 +40,16 @@ public class ServerboundChatPacket implements Packet<ServerGamePacketListener> {
|
|
}
|
|
|
|
// Spigot Start
|
|
- private static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool(
|
|
+ // Paper start - untrash chat event handling
|
|
+ public static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool(
|
|
new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon( true ).setNameFormat( "Async Chat Thread - #%d" ).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build() ); // Paper
|
|
public void handle(final ServerGamePacketListener listener) {
|
|
- if ( !this.message.startsWith("/") )
|
|
- {
|
|
- ServerboundChatPacket.executors.execute( new Runnable() // Paper - Use #execute to propagate exceptions up instead of swallowing them
|
|
- {
|
|
-
|
|
- @Override
|
|
- public void run()
|
|
- {
|
|
- listener.handleChat( ServerboundChatPacket.this );
|
|
- }
|
|
- } );
|
|
+ if (this.message.startsWith("/")) {
|
|
+ // Just don't allow this instead of creating gigantic diff when untrashing more Spigot code
|
|
return;
|
|
}
|
|
- // Spigot End
|
|
listener.handleChat(this);
|
|
+ // Paper end - untrash chat event handling
|
|
}
|
|
|
|
public String getMessage() {
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index a82f5516274c2e7b582d38c70cd116d23d0687c8..630a762b71861bfe21c47a11d4fe05e1a3b7d339 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2104,11 +2104,6 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
|
|
@Override
|
|
public void handleChat(ServerboundChatPacket packet) {
|
|
- // CraftBukkit start - async chat
|
|
- // SPIGOT-3638
|
|
- if (this.server.isStopped()) {
|
|
- return;
|
|
- }
|
|
// CraftBukkit end
|
|
if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.getMessage())) {
|
|
this.server.scheduleOnMain(() -> { // Paper - push to main for event firing
|
|
@@ -2118,8 +2113,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
if (this.tryHandleChat(packet.getMessage(), packet.getTimeStamp())) {
|
|
// CraftBukkit start
|
|
// this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
|
|
+ // Paper start - untrash chat handling
|
|
+ ServerboundChatPacket.executors.execute(() -> {
|
|
+ if (this.server.isStopped()) {
|
|
+ return;
|
|
+ }
|
|
this.handleChat(packet, FilteredText.passThrough(packet.getMessage())); // CraftBukkit - filter NYI
|
|
// });
|
|
+ });
|
|
+ // Paper end - untrash chat handling
|
|
// CraftBukkit end
|
|
}
|
|
|
|
@@ -2133,8 +2135,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
|
}); // Paper - push to main for event firing
|
|
} else {
|
|
- PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
+ // Paper start - untrash chat handling
|
|
if (this.tryHandleChat(packet.command(), packet.timeStamp())) {
|
|
+ this.server.scheduleOnMain(() -> {
|
|
// CraftBukkit start
|
|
// CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
|
|
|
|
@@ -2147,6 +2150,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
}
|
|
this.detectRateSpam(true, "/" + packet.command()); // Spigot
|
|
// CraftBukkit end
|
|
+ });
|
|
+ // Paper end - untrash chat handling
|
|
}
|
|
|
|
}
|