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:
Aikar
2016-03-03 01:17:12 -06:00
parent b380d6445b
commit bcc07d07b6
3 changed files with 43 additions and 31 deletions

View File

@@ -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