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-23 14:34:17 +01:00
|
|
|
index e8e5773776060b7b6861c80ec736bc5740a262c8..64b5af3745642d2a2e2075cb70ef4defbee64d15 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
|
2023-12-28 21:47:57 +01:00
|
|
|
@@ -1937,7 +1937,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
|
2023-12-29 01:50:06 +01:00
|
|
|
@@ -2024,7 +2024,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-23 14:34:17 +01:00
|
|
|
index 73ed8a00ed83a0f7da7a5f69e743850d7a5b76cc..7e7dfec65f1756e21eb79359e13d429fe1955bba 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-23 14:34:17 +01:00
|
|
|
index 49d0e2988d2267c4721d8ce37a96eb1d3944ea5a..1ebbd53d545d4b9ac3341c6a68ec97a2f468fb48 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
|
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
|
|
|
@@ -498,7 +498,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
|