package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;

public class ClientboundDisconnectPacket implements Packet<ClientGamePacketListener> {
    private Component reason;
    
    public ClientboundDisconnectPacket() {
    }
    
    public ClientboundDisconnectPacket(final Component lf) {
        this.reason = lf;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.reason = kv.readComponent();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeComponent(this.reason);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleDisconnect(this);
    }
    
    public Component getReason() {
        return this.reason;
    }
}
