use of net.minecraftforge.network.ConnectionType in project MinecraftForge by MinecraftForge.
the class ServerLifecycleHooks method handleServerLogin.
public static boolean handleServerLogin(final ClientIntentionPacket packet, final Connection manager) {
if (!allowLogins.get()) {
TextComponent text = new TextComponent("Server is still starting! Please wait before reconnecting.");
LOGGER.info(SERVERHOOKS, "Disconnecting Player (server is still starting): {}", text.getContents());
manager.send(new ClientboundLoginDisconnectPacket(text));
manager.disconnect(text);
return false;
}
if (packet.getIntention() == ConnectionProtocol.LOGIN) {
final ConnectionType connectionType = ConnectionType.forVersionFlag(packet.getFMLVersion());
final int versionNumber = connectionType.getFMLVersionNumber(packet.getFMLVersion());
if (connectionType == ConnectionType.MODDED && versionNumber != NetworkConstants.FMLNETVERSION) {
rejectConnection(manager, connectionType, "This modded server is not impl compatible with your modded client. Please verify your Forge version closely matches the server. Got net version " + versionNumber + " this server is net version " + NetworkConstants.FMLNETVERSION);
return false;
}
if (connectionType == ConnectionType.VANILLA && !NetworkRegistry.acceptsVanillaClientConnections()) {
rejectConnection(manager, connectionType, "This server has mods that require Forge to be installed on the client. Contact your server admin for more details.");
return false;
}
}
if (packet.getIntention() == ConnectionProtocol.STATUS)
return true;
NetworkHooks.registerServerLoginChannel(manager, packet);
return true;
}
Aggregations