Finalize modded handshakes in the World tick thread. Prevents potential CMEs when login event takes to long to fire.

This commit is contained in:
Lex Manos 2014-11-28 10:37:55 -08:00
parent 229848a4cb
commit 4a92959cc1
2 changed files with 15 additions and 4 deletions

View file

@ -19,7 +19,7 @@ public class WrongMinecraftVersionException extends RuntimeException
public WrongMinecraftVersionException(ModContainer mod)
{
super(String.format("Wrong Minecraft vbersion for %s", mod.getModId()));
super(String.format("Wrong Minecraft version for %s", mod.getModId()));
this.mod = mod;
}

View file

@ -47,7 +47,7 @@ import net.minecraftforge.fml.relauncher.Side;
public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> implements ChannelOutboundHandler {
private static boolean DEBUG_HANDSHAKE = Boolean.parseBoolean(System.getProperty("fml.debugNetworkHandshake", "false"));
private static enum ConnectionState {
OPENING, AWAITING_HANDSHAKE, HANDSHAKING, HANDSHAKECOMPLETE, CONNECTED;
OPENING, AWAITING_HANDSHAKE, HANDSHAKING, HANDSHAKECOMPLETE, FINALIZING, CONNECTED;
}
private static enum ConnectionType {
@ -161,7 +161,18 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
// This will be ignored by vanilla clients
this.state = ConnectionState.AWAITING_HANDSHAKE;
// Need to start the handler here, so we can send custompayload packets
serverHandler = new NetHandlerPlayServer(scm.getServerInstance(), manager, player);
serverHandler = new NetHandlerPlayServer(scm.getServerInstance(), manager, player)
{
@Override
public void update()
{
if (NetworkDispatcher.this.state == ConnectionState.FINALIZING)
{
completeServerSideConnection(ConnectionType.MODDED);
}
super.update();
}
};
this.netHandler = serverHandler;
// NULL the play server here - we restore it further on. If not, there are packets sent before the login
player.playerNetServerHandler = null;
@ -478,7 +489,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
}
else
{
completeServerSideConnection(ConnectionType.MODDED);
this.state = ConnectionState.FINALIZING; //Delay and finalize in the world tick loop.
}
}