package protocolsupport.protocol.packet.middleimpl.writeable.play.v_pe;

import io.netty.buffer.ByteBuf;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.protocol.packet.Chat;
import protocolsupport.protocol.packet.id.PEPacketId;
import protocolsupport.protocol.packet.middleimpl.writeable.PESingleWriteablePacket;
import protocolsupport.protocol.serializer.StringSerializer;
import protocolsupport.protocol.serializer.VarNumberSerializer;

public class ToClientChatPacket extends PESingleWriteablePacket<Chat> {

	public ToClientChatPacket() {
		super(PEPacketId.Dualbound.PLAY_CHAT);
	}

	@Override
	protected void write(ByteBuf data, Chat packet) {
		data.writeByte(packet.getPosition() == 2 ? 5 : 0); //type
		data.writeByte(0); //isLocalise?
		StringSerializer.writeVarIntUTF8String(data, ""); //Source name (sender)
		StringSerializer.writeVarIntUTF8String(data, ""); //Third Party Platform
		VarNumberSerializer.writeSVarInt(data, 0); //Source platform
		StringSerializer.writeVarIntUTF8String(data, ComponentSerializer.parse(packet.getMessage())[0].toLegacyText());
		StringSerializer.writeVarIntUTF8String(data, ""); //Xbox user ID
		StringSerializer.writeVarIntUTF8String(data, ""); //Platform Chat ID
	}

}

@@ -395,72 +395,8 @@
 zer;
-%0Aimport protocolsupport.protocol.serializer.VarNumberSerializer;
 %0A%0Apu
@@ -703,221 +703,8 @@
 se?%0A
-%09%09StringSerializer.writeVarIntUTF8String(data, %22%22); //Source name (sender)%0A%09%09StringSerializer.writeVarIntUTF8String(data, %22%22); //Third Party Platform%0A%09%09VarNumberSerializer.writeSVarInt(data, 0); //Source platform%0A
 %09%09St

Fix 1.4.x chat