    001    package cpw.mods.fml.common.modloader;
    002
    003    import net.minecraft.server.MinecraftServer;
    004    import net.minecraft.src.EntityPlayer;
    005    import net.minecraft.src.NetHandler;
    006    import net.minecraft.src.NetLoginHandler;
    007    import net.minecraft.src.INetworkManager;
    008    import net.minecraft.src.Packet1Login;
    009    import cpw.mods.fml.common.network.IConnectionHandler;
    010    import cpw.mods.fml.common.network.Player;
    011
    012    public class ModLoaderConnectionHandler implements IConnectionHandler
    013    {
    014        private BaseModProxy mod;
    015
    016        public ModLoaderConnectionHandler(BaseModProxy mod)
    017        {
    018            this.mod = mod;
    019        }
    020
    021        @Override
    022        public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
    023        {
    024            mod.onClientLogin((EntityPlayer)player);
    025        }
    026
    027        @Override
    028        public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
    029        {
    030            return null;
    031        }
    032
    033        @Override
    034        public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager)
    035        {
    036            ModLoaderHelper.sidedHelper.clientConnectionOpened(netClientHandler, manager, mod);
    037        }
    038
    039        @Override
    040        public void connectionClosed(INetworkManager manager)
    041        {
    042            if (!ModLoaderHelper.sidedHelper.clientConnectionClosed(manager, mod))
    043            {
    044                mod.serverDisconnect();
    045                mod.onClientLogout(manager);
    046            }
    047        }
    048
    049        @Override
    050        public void clientLoggedIn(NetHandler nh, INetworkManager manager, Packet1Login login)
    051        {
    052            mod.serverConnect(nh);
    053        }
    054
    055        @Override
    056        public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager)
    057        {
    058            ModLoaderHelper.sidedHelper.clientConnectionOpened(netClientHandler, manager, mod);
    059        }
    060
    061    }