/** * Handles the Forge packet. * * @param message The Forge Handshake packet to handle. */ public void handle(PluginMessage message) throws IllegalArgumentException { if (!message.getTag().equalsIgnoreCase(ForgeConstants.FML_HANDSHAKE_TAG)) { throw new IllegalArgumentException("Expecting a Forge Handshake packet."); } message.setAllowExtendedPacket(true); // FML allows extended packets so this must be enabled ForgeClientHandshakeState prevState = state; packetQueue.add(message); state = state.send(message, con); if (state != prevState) // state finished, send packets { synchronized (packetQueue) { while (!packetQueue.isEmpty()) { ForgeLogger.logClient( ForgeLogger.LogDirection.SENDING, prevState.name(), packetQueue.getFirst()); con.getForgeServerHandler().receive(packetQueue.removeFirst()); } } } }
/** * Receives a {@link PluginMessage} from ForgeServer to pass to Client. * * @param message The message to being received. */ public void receive(PluginMessage message) throws IllegalArgumentException { state = state.handle(message, con); }