fix player messages

This commit is contained in:
Chipmunk 2023-04-30 22:39:27 -04:00
parent cee88ffa3d
commit f5db2e02a3

View file

@ -86,7 +86,18 @@ public class ChatPlugin extends SessionAdapter {
public void packetReceived (Session session, ClientboundPlayerChatPacket packet) {
final MutablePlayerListEntry sender = client.playerList().getEntry(packet.getSender());
if (sender == null) return;
final PlayerMessage playerMessage = new PlayerMessage(sender, packet.getUnsignedContent(), "minecraft:chat", packet.getName()); // TODO: Fix chatType
PlayerMessage parsedFromMessage = null;
final Component component = packet.getUnsignedContent();
for (SystemChatParser parser : systemChatParsers) {
parsedFromMessage = parser.parse(component);
if (parsedFromMessage != null) break;
}
if (parsedFromMessage == null) return;
final PlayerMessage playerMessage = new PlayerMessage(sender, parsedFromMessage.contents(), "minecraft:chat", packet.getName()); // TODO: Fix chatType
for (Listener listener : this.listeners) {
listener.playerMessageReceived(playerMessage);