DimDoors/StevenDimDoors/mod_pocketDim/ConnectionHandler.java
2013-02-17 21:46:16 -05:00

79 lines
No EOL
1.8 KiB
Java

package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player;
public class ConnectionHandler
implements IConnectionHandler
{
private static boolean connected = false;
//sends a packet to clients containing all the information about the dims and links. Lots of packets, actually.
@Override
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
{
Collection set = new ArrayList();
set.addAll(dimHelper.dimList.keySet());
PacketHandler.onClientJoinPacket(manager, dimHelper.dimList);
PacketHandler.onDimCreatedPacket(new DimData(mod_pocketDim.limboDimID, false, 0, 0, 0, 0, 0));
return null;
}
@Override
public void connectionOpened(NetHandler netClientHandler, String server,int port, INetworkManager manager)
{
connected = true;
}
@Override
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager)
{
}
@Override
public void connectionClosed(INetworkManager manager)
{
if (connected)
{
System.out.println("Clearing dim cache");
dimHelper.instance.save();
dimHelper.instance.unregsisterDims();
dimHelper.dimList.clear();
dimHelper.instance.linksForRendering.clear();
}
connected = false;
}
@Override
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager,
Packet1Login login)
{
}
@Override
public void playerLoggedIn(Player player, NetHandler netHandler,
INetworkManager manager)
{
}
}