2023-09-17 00:54:33 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Thu, 3 Mar 2016 01:17:12 -0600
|
|
|
|
Subject: [PATCH] Improve Player chat API handling
|
|
|
|
|
|
|
|
Properly split up the chat and command handling to reflect the server now
|
|
|
|
having separate packets for both, and the client always using the correct packet. Text
|
|
|
|
from a chat packet should never be parsed into a command, even if it starts with the `/`
|
|
|
|
character.
|
|
|
|
|
|
|
|
Add a missing async catcher and improve Spigot's async catcher error message.
|
|
|
|
|
|
|
|
== AT ==
|
|
|
|
public net.minecraft.server.network.ServerGamePacketListenerImpl isChatMessageIllegal(Ljava/lang/String;)Z
|
|
|
|
|
|
|
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2024-01-24 13:07:40 +01:00
|
|
|
index ce7caf08865df9ff032ba6c42308ea3ce4de6226..04e68886a5385234701962f2502948052074515e 100644
|
2023-09-17 00:54:33 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2024-01-24 13:07:40 +01:00
|
|
|
@@ -1930,7 +1930,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2023-09-17 00:54:33 +02:00
|
|
|
}
|
|
|
|
OutgoingChatMessage outgoing = OutgoingChatMessage.create(original);
|
|
|
|
|
|
|
|
- if (!async && s.startsWith("/")) {
|
|
|
|
+ if (false && !async && s.startsWith("/")) { // Paper - Don't handle commands in chat logic
|
|
|
|
this.handleCommand(s);
|
|
|
|
} else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) {
|
|
|
|
// Do nothing, this is coming from a plugin
|
2024-01-24 13:07:40 +01:00
|
|
|
@@ -2017,7 +2017,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2023-09-17 00:54:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- private void handleCommand(String s) {
|
|
|
|
+ public void handleCommand(String s) { // Paper - private -> public
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher
|
|
|
|
co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper
|
|
|
|
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
|
|
|
|
this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2024-01-24 13:07:40 +01:00
|
|
|
index 58c0fc6c0d5df7cd8331d742dc93aad37d6139c9..c370a3be48d3582eb23e0831a3e21798ade9affd 100644
|
2023-09-17 00:54:33 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -885,7 +885,7 @@ public final class CraftServer implements Server {
|
2023-09-17 00:54:33 +02:00
|
|
|
public boolean dispatchCommand(CommandSender sender, String commandLine) {
|
|
|
|
Preconditions.checkArgument(sender != null, "sender cannot be null");
|
|
|
|
Preconditions.checkArgument(commandLine != null, "commandLine cannot be null");
|
|
|
|
- org.spigotmc.AsyncCatcher.catchOp("command dispatch"); // Spigot
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + commandLine); // Spigot // Paper - Include command in error message
|
|
|
|
|
|
|
|
if (this.commandMap.dispatch(sender, commandLine)) {
|
|
|
|
return true;
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-01-24 13:07:40 +01:00
|
|
|
index 70a5ced9e39d6ce0e38f9ee04883584f40d49971..d37ff41c7266f6811988272e32e035469fe30f46 100644
|
2023-09-17 00:54:33 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-01-24 13:07:40 +01:00
|
|
|
@@ -456,7 +456,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2023-09-17 00:54:33 +02:00
|
|
|
|
|
|
|
if (this.getHandle().connection == null) return;
|
|
|
|
|
|
|
|
- this.getHandle().connection.chat(msg, PlayerChatMessage.system(msg), false);
|
|
|
|
+ // Paper start - Improve chat handling
|
|
|
|
+ if (ServerGamePacketListenerImpl.isChatMessageIllegal(msg)) {
|
|
|
|
+ this.getHandle().connection.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
|
|
|
+ } else {
|
|
|
|
+ if (msg.startsWith("/")) {
|
|
|
|
+ this.getHandle().connection.handleCommand(msg);
|
|
|
|
+ } else {
|
|
|
|
+ final PlayerChatMessage playerChatMessage = PlayerChatMessage.system(msg).withResult(new net.minecraft.network.chat.ChatDecorator.ModernResult(Component.literal(msg), true, false));
|
|
|
|
+ // TODO chat decorating
|
|
|
|
+ // TODO text filtering
|
|
|
|
+ this.getHandle().connection.chat(msg, playerChatMessage, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-23 14:34:17 +01:00
|
|
|
+ // Paper end - Improve chat handling
|
2023-09-17 00:54:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|