// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.protocol.packets.interface_;

import java.util.Objects;
import com.hypixel.hytale.protocol.io.ValidationResult;
import com.hypixel.hytale.protocol.io.PacketIO;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
import java.util.UUID;

public class ServerPlayerListUpdate
{
    public static final int NULLABLE_BIT_FIELD_SIZE = 0;
    public static final int FIXED_BLOCK_SIZE = 32;
    public static final int VARIABLE_FIELD_COUNT = 0;
    public static final int VARIABLE_BLOCK_START = 32;
    public static final int MAX_SIZE = 32;
    @Nonnull
    public UUID uuid;
    @Nonnull
    public UUID worldUuid;
    
    public ServerPlayerListUpdate() {
        this.uuid = new UUID(0L, 0L);
        this.worldUuid = new UUID(0L, 0L);
    }
    
    public ServerPlayerListUpdate(@Nonnull final UUID uuid, @Nonnull final UUID worldUuid) {
        this.uuid = new UUID(0L, 0L);
        this.worldUuid = new UUID(0L, 0L);
        this.uuid = uuid;
        this.worldUuid = worldUuid;
    }
    
    public ServerPlayerListUpdate(@Nonnull final ServerPlayerListUpdate other) {
        this.uuid = new UUID(0L, 0L);
        this.worldUuid = new UUID(0L, 0L);
        this.uuid = other.uuid;
        this.worldUuid = other.worldUuid;
    }
    
    @Nonnull
    public static ServerPlayerListUpdate deserialize(@Nonnull final ByteBuf buf, final int offset) {
        final ServerPlayerListUpdate obj = new ServerPlayerListUpdate();
        obj.uuid = PacketIO.readUUID(buf, offset + 0);
        obj.worldUuid = PacketIO.readUUID(buf, offset + 16);
        return obj;
    }
    
    public static int computeBytesConsumed(@Nonnull final ByteBuf buf, final int offset) {
        return 32;
    }
    
    public void serialize(@Nonnull final ByteBuf buf) {
        PacketIO.writeUUID(buf, this.uuid);
        PacketIO.writeUUID(buf, this.worldUuid);
    }
    
    public int computeSize() {
        return 32;
    }
    
    public static ValidationResult validateStructure(@Nonnull final ByteBuf buffer, final int offset) {
        if (buffer.readableBytes() - offset < 32) {
            return ValidationResult.error("Buffer too small: expected at least 32 bytes");
        }
        return ValidationResult.OK;
    }
    
    public ServerPlayerListUpdate clone() {
        final ServerPlayerListUpdate copy = new ServerPlayerListUpdate();
        copy.uuid = this.uuid;
        copy.worldUuid = this.worldUuid;
        return copy;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof final ServerPlayerListUpdate other) {
            return Objects.equals(this.uuid, other.uuid) && Objects.equals(this.worldUuid, other.worldUuid);
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.uuid, this.worldUuid);
    }
}
