minecraft-src/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java
2025-07-04 01:41:11 +03:00

32 lines
1,000 B
Java

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<ServerGamePacketListener> {
public static final StreamCodec<FriendlyByteBuf, ServerboundChatCommandPacket> 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<ServerboundChatCommandPacket> type() {
return GamePacketTypes.SERVERBOUND_CHAT_COMMAND;
}
/**
* Passes this Packet on to the PacketListener for processing.
*/
public void handle(ServerGamePacketListener handler) {
handler.handleChatCommand(this);
}
}