    001package net.minecraft.client.multiplayer;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.net.InetAddress;
    006import java.util.ArrayList;
    007import java.util.Collections;
    008import java.util.Iterator;
    009import java.util.List;
    010
    011@SideOnly(Side.CLIENT)
    012public class LanServerList
    013{
    014    private ArrayList listOfLanServers = new ArrayList();
    015    boolean wasUpdated;
    016
    017    public synchronized boolean getWasUpdated()
    018    {
    019        return this.wasUpdated;
    020    }
    021
    022    public synchronized void setWasNotUpdated()
    023    {
    024        this.wasUpdated = false;
    025    }
    026
    027    public synchronized List getLanServers()
    028    {
    029        return Collections.unmodifiableList(this.listOfLanServers);
    030    }
    031
    032    public synchronized void func_77551_a(String par1Str, InetAddress par2InetAddress)
    033    {
    034        String s1 = ThreadLanServerPing.getMotdFromPingResponse(par1Str);
    035        String s2 = ThreadLanServerPing.getAdFromPingResponse(par1Str);
    036
    037        if (s2 != null)
    038        {
    039            int i = s2.indexOf(58);
    040
    041            if (i > 0)
    042            {
    043                s2 = par2InetAddress.getHostAddress() + s2.substring(i);
    044            }
    045
    046            boolean flag = false;
    047            Iterator iterator = this.listOfLanServers.iterator();
    048
    049            while (iterator.hasNext())
    050            {
    051                LanServer lanserver = (LanServer)iterator.next();
    052
    053                if (lanserver.getServerIpPort().equals(s2))
    054                {
    055                    lanserver.updateLastSeen();
    056                    flag = true;
    057                    break;
    058                }
    059            }
    060
    061            if (!flag)
    062            {
    063                this.listOfLanServers.add(new LanServer(s1, s2));
    064                this.wasUpdated = true;
    065            }
    066        }
    067    }
    068}