package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketType; public record ServerboundChatCommandPacket(String command) implements Packet { public static final StreamCodec STREAM_CODEC = Packet.codec( ServerboundChatCommandPacket::write, ServerboundChatCommandPacket::new ); private ServerboundChatCommandPacket(FriendlyByteBuf buffer) { this(buffer.readUtf()); } private void write(FriendlyByteBuf buffer) { buffer.writeUtf(this.command); } @Override public PacketType type() { return GamePacketTypes.SERVERBOUND_CHAT_COMMAND; } public void handle(ServerGamePacketListener serverGamePacketListener) { serverGamePacketListener.handleChatCommand(this); } }