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 mr) {
        this.reason = mr;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.reason = mg.readComponent();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeComponent(this.reason);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleDisconnect(this);
    }
    
    public Component getReason() {
        return this.reason;
    }
}
