package net.minecraft.network.protocol.login;

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 ClientboundLoginDisconnectPacket implements Packet<ClientLoginPacketListener> {
    private Component reason;
    
    public ClientboundLoginDisconnectPacket() {
    }
    
    public ClientboundLoginDisconnectPacket(final Component mr) {
        this.reason = mr;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.reason = Component.Serializer.fromJsonLenient(mg.readUtf(262144));
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeComponent(this.reason);
    }
    
    @Override
    public void handle(final ClientLoginPacketListener sw) {
        sw.handleDisconnect(this);
    }
    
    public Component getReason() {
        return this.reason;
    }
}
