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 mg) throws IOException {
        this.url = mg.readUtf(32767);
        this.hash = mg.readUtf(40);
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeUtf(this.url);
        mg.writeUtf(this.hash);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleResourcePack(this);
    }
    
    public String getUrl() {
        return this.url;
    }
    
    public String getHash() {
        return this.hash;
    }
}
