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>
This commit is contained in:
@@ -563,7 +563,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
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).withUnsignedContent(Component.literal(msg));
|
||||
// TODO chat decorating
|
||||
// TODO text filtering
|
||||
this.getHandle().connection.chat(msg, playerChatMessage, false);
|
||||
}
|
||||
}
|
||||
// Paper end - Improve chat handling
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user