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

package com.hypixel.hytale.server.core.auth;

import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import com.hypixel.hytale.protocol.HostAddress;
import java.util.UUID;

public class PlayerAuthentication
{
    public static final int MAX_REFERRAL_DATA_SIZE = 4096;
    private UUID uuid;
    private String username;
    private byte[] referralData;
    private HostAddress referralSource;
    
    public PlayerAuthentication() {
    }
    
    public PlayerAuthentication(@Nonnull final UUID uuid, @Nonnull final String username) {
        this.uuid = uuid;
        this.username = username;
    }
    
    @Nonnull
    public String getUsername() {
        if (this.username == null) {
            throw new UnsupportedOperationException("Username not set - incomplete authentication");
        }
        return this.username;
    }
    
    @Nonnull
    public UUID getUuid() {
        if (this.uuid == null) {
            throw new UnsupportedOperationException("UUID not set - incomplete authentication");
        }
        return this.uuid;
    }
    
    public void setUsername(@Nonnull final String username) {
        this.username = username;
    }
    
    public void setUuid(@Nonnull final UUID uuid) {
        this.uuid = uuid;
    }
    
    @Nullable
    public byte[] getReferralData() {
        return this.referralData;
    }
    
    public void setReferralData(@Nullable final byte[] referralData) {
        if (referralData != null && referralData.length > 4096) {
            throw new IllegalArgumentException("Referral data exceeds maximum size of 4096 bytes (got " + referralData.length);
        }
        this.referralData = referralData;
    }
    
    @Nullable
    public HostAddress getReferralSource() {
        return this.referralSource;
    }
    
    public void setReferralSource(@Nullable final HostAddress referralSource) {
        this.referralSource = referralSource;
    }
}
