    001package net.minecraft.client.multiplayer;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.nbt.NBTTagCompound;
    006
    007@SideOnly(Side.CLIENT)
    008public class ServerData
    009{
    010    public String serverName;
    011    public String serverIP;
    012
    013    /**
    014     * the string indicating number of players on and capacity of the server that is shown on the server browser (i.e.
    015     * "5/20" meaning 5 slots used out of 20 slots total)
    016     */
    017    public String populationInfo;
    018
    019    /**
    020     * (better variable name would be 'hostname') server name as displayed in the server browser's second line (grey
    021     * text)
    022     */
    023    public String serverMOTD;
    024
    025    /** last server ping that showed up in the server browser */
    026    public long pingToServer;
    027    public int field_82821_f = 60;
    028
    029    /** Game version for this server. */
    030    public String gameVersion = "1.5";
    031    public boolean field_78841_f = false;
    032    private boolean field_78842_g = true;
    033    private boolean acceptsTextures = false;
    034
    035    /** Whether to hide the IP address for this server. */
    036    private boolean hideAddress = false;
    037
    038    public ServerData(String par1Str, String par2Str)
    039    {
    040        this.serverName = par1Str;
    041        this.serverIP = par2Str;
    042    }
    043
    044    /**
    045     * Returns an NBTTagCompound with the server's name, IP and maybe acceptTextures.
    046     */
    047    public NBTTagCompound getNBTCompound()
    048    {
    049        NBTTagCompound nbttagcompound = new NBTTagCompound();
    050        nbttagcompound.setString("name", this.serverName);
    051        nbttagcompound.setString("ip", this.serverIP);
    052        nbttagcompound.setBoolean("hideAddress", this.hideAddress);
    053
    054        if (!this.field_78842_g)
    055        {
    056            nbttagcompound.setBoolean("acceptTextures", this.acceptsTextures);
    057        }
    058
    059        return nbttagcompound;
    060    }
    061
    062    public boolean getAcceptsTextures()
    063    {
    064        return this.acceptsTextures;
    065    }
    066
    067    public boolean func_78840_c()
    068    {
    069        return this.field_78842_g;
    070    }
    071
    072    public void setAcceptsTextures(boolean par1)
    073    {
    074        this.acceptsTextures = par1;
    075        this.field_78842_g = false;
    076    }
    077
    078    public boolean isHidingAddress()
    079    {
    080        return this.hideAddress;
    081    }
    082
    083    public void setHideAddress(boolean par1)
    084    {
    085        this.hideAddress = par1;
    086    }
    087
    088    /**
    089     * Takes an NBTTagCompound with 'name' and 'ip' keys, returns a ServerData instance.
    090     */
    091    public static ServerData getServerDataFromNBTCompound(NBTTagCompound par0NBTTagCompound)
    092    {
    093        ServerData serverdata = new ServerData(par0NBTTagCompound.getString("name"), par0NBTTagCompound.getString("ip"));
    094        serverdata.hideAddress = par0NBTTagCompound.getBoolean("hideAddress");
    095
    096        if (par0NBTTagCompound.hasKey("acceptTextures"))
    097        {
    098            serverdata.setAcceptsTextures(par0NBTTagCompound.getBoolean("acceptTextures"));
    099        }
    100
    101        return serverdata;
    102    }
    103}