    001package net.minecraft.client.mco;
    002
    003import argo.jdom.JdomParser;
    004import argo.jdom.JsonNode;
    005import argo.saj.InvalidSyntaxException;
    006import cpw.mods.fml.relauncher.Side;
    007import cpw.mods.fml.relauncher.SideOnly;
    008import java.io.UnsupportedEncodingException;
    009import java.net.URLDecoder;
    010import java.util.ArrayList;
    011import java.util.Iterator;
    012import java.util.List;
    013import net.minecraft.util.ValueObject;
    014
    015@SideOnly(Side.CLIENT)
    016public class McoServer extends ValueObject implements Comparable
    017{
    018    public long field_96408_a;
    019    public String field_96406_b;
    020    public String field_96407_c;
    021    public String field_96404_d;
    022    public String field_96405_e;
    023    public List field_96402_f;
    024    public String field_96403_g;
    025    public boolean field_98166_h;
    026    public int field_96415_h;
    027    public int field_96416_i;
    028    public String field_96413_j = "";
    029    public String field_96414_k = "";
    030    public boolean field_96411_l;
    031    public long field_96412_m;
    032    private String field_96409_n = null;
    033    private String field_96410_o = null;
    034
    035    public String func_96397_a()
    036    {
    037        if (this.field_96409_n == null)
    038        {
    039            try
    040            {
    041                this.field_96409_n = URLDecoder.decode(this.field_96407_c, "UTF-8");
    042            }
    043            catch (UnsupportedEncodingException unsupportedencodingexception)
    044            {
    045                this.field_96409_n = this.field_96407_c;
    046            }
    047        }
    048
    049        return this.field_96409_n;
    050    }
    051
    052    public String func_96398_b()
    053    {
    054        if (this.field_96410_o == null)
    055        {
    056            try
    057            {
    058                this.field_96410_o = URLDecoder.decode(this.field_96406_b, "UTF-8");
    059            }
    060            catch (UnsupportedEncodingException unsupportedencodingexception)
    061            {
    062                this.field_96410_o = this.field_96406_b;
    063            }
    064        }
    065
    066        return this.field_96410_o;
    067    }
    068
    069    public void func_96399_a(String par1Str)
    070    {
    071        this.field_96406_b = par1Str;
    072        this.field_96410_o = null;
    073    }
    074
    075    public void func_96400_b(String par1Str)
    076    {
    077        this.field_96407_c = par1Str;
    078        this.field_96409_n = null;
    079    }
    080
    081    public void func_96401_a(McoServer par1McoServer)
    082    {
    083        this.field_96414_k = par1McoServer.field_96414_k;
    084        this.field_96413_j = par1McoServer.field_96413_j;
    085        this.field_96416_i = par1McoServer.field_96416_i;
    086        this.field_96412_m = par1McoServer.field_96412_m;
    087        this.field_96411_l = par1McoServer.field_96411_l;
    088        this.field_96415_h = par1McoServer.field_96415_h;
    089    }
    090
    091    public static McoServer func_98163_a(JsonNode par0JsonNode)
    092    {
    093        McoServer mcoserver = new McoServer();
    094
    095        try
    096        {
    097            mcoserver.field_96408_a = Long.parseLong(par0JsonNode.getNumberValue(new Object[] {"id"}));
    098            mcoserver.field_96406_b = par0JsonNode.getStringValue(new Object[] {"name"});
    099            mcoserver.field_96407_c = par0JsonNode.getStringValue(new Object[] {"motd"});
    100            mcoserver.field_96404_d = par0JsonNode.getStringValue(new Object[] {"state"});
    101            mcoserver.field_96405_e = par0JsonNode.getStringValue(new Object[] {"owner"});
    102
    103            if (par0JsonNode.isArrayNode(new Object[] {"invited"}))
    104            {
    105                mcoserver.field_96402_f = func_98164_a(par0JsonNode.getArrayNode(new Object[] {"invited"}));
    106            }
    107            else
    108            {
    109                mcoserver.field_96402_f = new ArrayList();
    110            }
    111
    112            mcoserver.field_96403_g = par0JsonNode.getStringValue(new Object[] {"ip"});
    113            mcoserver.field_98166_h = par0JsonNode.getBooleanValue(new Object[] {"expired"}).booleanValue();
    114        }
    115        catch (IllegalArgumentException illegalargumentexception)
    116        {
    117            ;
    118        }
    119
    120        return mcoserver;
    121    }
    122
    123    private static List func_98164_a(List par0List)
    124    {
    125        ArrayList arraylist = new ArrayList();
    126        Iterator iterator = par0List.iterator();
    127
    128        while (iterator.hasNext())
    129        {
    130            JsonNode jsonnode = (JsonNode)iterator.next();
    131            arraylist.add(jsonnode.getStringValue(new Object[0]));
    132        }
    133
    134        return arraylist;
    135    }
    136
    137    public static McoServer func_98165_c(String par0Str)
    138    {
    139        McoServer mcoserver = new McoServer();
    140
    141        try
    142        {
    143            mcoserver = func_98163_a((new JdomParser()).parse(par0Str));
    144        }
    145        catch (InvalidSyntaxException invalidsyntaxexception)
    146        {
    147            ;
    148        }
    149
    150        return mcoserver;
    151    }
    152
    153    public int func_101017_b(McoServer par1McoServer)
    154    {
    155        if (this.field_96405_e.equals(par1McoServer.field_96405_e))
    156        {
    157            return this.field_96408_a < par1McoServer.field_96408_a ? 1 : (this.field_96408_a > par1McoServer.field_96408_a ? -1 : 0);
    158        }
    159        else
    160        {
    161            if (this.field_96404_d.equals("CLOSED") || par1McoServer.field_96404_d.equals("CLOSED"))
    162            {
    163                if (this.field_96404_d.equals("CLOSED"))
    164                {
    165                    return 1;
    166                }
    167
    168                if (par1McoServer.field_96404_d.equals("CLOSED"))
    169                {
    170                    return 0;
    171                }
    172            }
    173
    174            return this.field_96408_a < par1McoServer.field_96408_a ? 1 : (this.field_96408_a > par1McoServer.field_96408_a ? -1 : 0);
    175        }
    176    }
    177
    178    public int compareTo(Object par1Obj)
    179    {
    180        return this.func_101017_b((McoServer)par1Obj);
    181    }
    182}