package net.minecraft.client.multiplayer;

import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.nbt.CompoundTag;
import java.util.Collections;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.SharedConstants;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.network.chat.Component;

public class ServerData {
    public String name;
    public String ip;
    public Component status;
    public Component motd;
    public long ping;
    public int protocol;
    public Component version;
    public boolean pinged;
    public List<Component> playerList;
    private ServerPackStatus packStatus;
    @Nullable
    private String iconB64;
    private boolean lan;
    
    public ServerData(final String string1, final String string2, final boolean boolean3) {
        this.protocol = SharedConstants.getCurrentVersion().getProtocolVersion();
        this.version = new TextComponent(SharedConstants.getCurrentVersion().getName());
        this.playerList = Collections.<Component>emptyList();
        this.packStatus = ServerPackStatus.PROMPT;
        this.name = string1;
        this.ip = string2;
        this.lan = boolean3;
    }
    
    public CompoundTag write() {
        final CompoundTag le2 = new CompoundTag();
        le2.putString("name", this.name);
        le2.putString("ip", this.ip);
        if (this.iconB64 != null) {
            le2.putString("icon", this.iconB64);
        }
        if (this.packStatus == ServerPackStatus.ENABLED) {
            le2.putBoolean("acceptTextures", true);
        }
        else if (this.packStatus == ServerPackStatus.DISABLED) {
            le2.putBoolean("acceptTextures", false);
        }
        return le2;
    }
    
    public ServerPackStatus getResourcePackStatus() {
        return this.packStatus;
    }
    
    public void setResourcePackStatus(final ServerPackStatus a) {
        this.packStatus = a;
    }
    
    public static ServerData read(final CompoundTag le) {
        final ServerData dys2 = new ServerData(le.getString("name"), le.getString("ip"), false);
        if (le.contains("icon", 8)) {
            dys2.setIconB64(le.getString("icon"));
        }
        if (le.contains("acceptTextures", 1)) {
            if (le.getBoolean("acceptTextures")) {
                dys2.setResourcePackStatus(ServerPackStatus.ENABLED);
            }
            else {
                dys2.setResourcePackStatus(ServerPackStatus.DISABLED);
            }
        }
        else {
            dys2.setResourcePackStatus(ServerPackStatus.PROMPT);
        }
        return dys2;
    }
    
    @Nullable
    public String getIconB64() {
        return this.iconB64;
    }
    
    public void setIconB64(@Nullable final String string) {
        this.iconB64 = string;
    }
    
    public boolean isLan() {
        return this.lan;
    }
    
    public void copyFrom(final ServerData dys) {
        this.ip = dys.ip;
        this.name = dys.name;
        this.setResourcePackStatus(dys.getResourcePackStatus());
        this.iconB64 = dys.iconB64;
        this.lan = dys.lan;
    }
    
    public enum ServerPackStatus {
        ENABLED("enabled"), 
        DISABLED("disabled"), 
        PROMPT("prompt");
        
        private final Component name;
        
        private ServerPackStatus(final String string3) {
            this.name = new TranslatableComponent("addServer.resourcePack." + string3);
        }
        
        public Component getName() {
            return this.name;
        }
    }
}
