2013-02-18 03:46:16 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
2013-06-10 23:03:52 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
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;
|
|
|
|
|
2013-04-30 01:03:38 +02:00
|
|
|
public class ConnectionHandler implements IConnectionHandler
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
|
|
|
private static boolean connected = false;
|
2013-06-14 01:01:54 +02:00
|
|
|
private static DDProperties properties = null;
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
//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)
|
|
|
|
{
|
2013-06-14 01:01:54 +02:00
|
|
|
if (properties == null)
|
|
|
|
properties = DDProperties.instance();
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
Collection set = new ArrayList();
|
|
|
|
set.addAll(dimHelper.dimList.keySet());
|
|
|
|
PacketHandler.onClientJoinPacket(manager, dimHelper.dimList);
|
2013-06-14 01:01:54 +02:00
|
|
|
PacketHandler.onDimCreatedPacket(new DimData(properties.LimboDimensionID, false, 0, 0, 0, 0, 0));
|
2013-02-18 03:46:16 +01:00
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
connected = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager,
|
|
|
|
Packet1Login login)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void playerLoggedIn(Player player, NetHandler netHandler,
|
|
|
|
INetworkManager manager)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|