Allow sending packets to client from ServerConnectionFromClientEvent (#4991)

This commit is contained in:
Ben Staddon authored and LexManos committed 2018-08-16 13:03:32 -07:00
1 parent 1f58bd71c0
commit 1171668c25
4 files changed
+48 -20

No files matched your search

@@ -67,6 +67,7 @@ import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.thread.SidedThreadGroup;
import net.minecraftforge.fml.relauncher.CoreModManager;
@@ -614,6 +615,11 @@ public class FMLCommonHandler
return sidedDelegate.shouldAllowPlayerLogins();
}
public void fireServerConnectionEvent(NetworkManager manager)
{
bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
}
/**
* Process initial Handshake packet, kicks players from the server if they are connecting while we are starting up.
* Also verifies the client has the FML marker.
@@ -250,7 +250,6 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet<?>> im
this.connectionType = type;
FMLLog.log.info("[{}] Server side {} connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
this.state = ConnectionState.CONNECTED;
MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
if (DEBUG_HANDSHAKE)
manager.closeChannel(new TextComponentString("Handshake Complete review log file for details."));
scm.initializeConnectionToPlayer(manager, player, serverHandler);