package net.minecraft.network.protocol.game;

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

public class ClientboundResourcePackPacket implements Packet<ClientGamePacketListener> {
    private String url;
    private String hash;
    
    public ClientboundResourcePackPacket() {
    }
    
    public ClientboundResourcePackPacket(final String string1, final String string2) {
        this.url = string1;
        this.hash = string2;
        if (string2.length() > 40) {
            throw new IllegalArgumentException("Hash is too long (max 40, was " + string2.length() + ")");
        }
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.url = kv.readUtf(32767);
        this.hash = kv.readUtf(40);
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeUtf(this.url);
        kv.writeUtf(this.hash);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleResourcePack(this);
    }
    
    public String getUrl() {
        return this.url;
    }
    
    public String getHash() {
        return this.hash;
    }
}
