/** * Sends the server ID list to the client, or stores it for sending later. * * @param idList The {@link PluginMessage} to send to the client containing * the ID list. * @throws IllegalArgumentException Thrown if the {@link PluginMessage} was * not as expected. */ public void setServerIdList(PluginMessage idList) throws IllegalArgumentException { if ( !idList.getTag().equalsIgnoreCase( ForgeConstants.FML_HANDSHAKE_TAG ) || idList.getData()[0] != 3 ) { throw new IllegalArgumentException( "idList" ); } this.serverIdList = idList; }
/** * Sends the server mod list to the client, or stores it for sending later. * * @param modList The {@link PluginMessage} to send to the client containing * the mod list. * @throws IllegalArgumentException Thrown if the {@link PluginMessage} was * not as expected. */ public void setServerModList(PluginMessage modList) throws IllegalArgumentException { if ( !modList.getTag().equalsIgnoreCase( ForgeConstants.FML_HANDSHAKE_TAG ) || modList.getData()[0] != 2 ) { throw new IllegalArgumentException( "modList" ); } this.serverModList = modList; }
@Override public ForgeServerHandshakeState send(PluginMessage message, UserConnection con) { if ( message.getData()[0] == 3 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) { con.getForgeClientHandler().setServerIdList( message ); return this; } if ( message.getData()[0] == -1 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) // transition to COMPLETE after sending ACK { return this; } if ( message.getTag().equals( ForgeConstants.FORGE_REGISTER ) ) // wait for Forge channel registration { return COMPLETE; } return this; } },
static void logServer(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Server -> Bungee" : "Server <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
static void logClient(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Client -> Bungee" : "Client <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
/** * Handles any {@link PluginMessage} that contains a FML Handshake or Forge * Register. * * @param message The message to handle. * @throws IllegalArgumentException If the wrong packet is sent down. */ public void handle(PluginMessage message) throws IllegalArgumentException { if ( !message.getTag().equalsIgnoreCase( ForgeConstants.FML_HANDSHAKE_TAG ) && !message.getTag().equalsIgnoreCase( ForgeConstants.FORGE_REGISTER ) ) { throw new IllegalArgumentException( "Expecting a Forge REGISTER or FML Handshake packet." ); } message.setAllowExtendedPacket( true ); // FML allows extended packets so this must be enabled ForgeServerHandshakeState prevState = state; packetQueue.add( message ); state = state.send( message, con ); if ( state != prevState ) // send packets { synchronized ( packetQueue ) { while ( !packetQueue.isEmpty() ) { ForgeLogger.logServer( LogDirection.SENDING, prevState.name(), packetQueue.getFirst() ); con.getForgeClientHandler().receive( packetQueue.removeFirst() ); } } } }
/** * 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; Preconditions.checkState( packetQueue.size() < 128, "Forge packet queue too big!" ); 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() ); } } } }
@Override public void handle(PluginMessage pluginMessage) throws Exception if ( pluginMessage.getTag().equals( "BungeeCord" ) ) if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 ) if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() ); if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
PluginMessageEvent event = new PluginMessageEvent( server, con, pluginMessage.getTag(), pluginMessage.getData().clone() ); if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) ) if ( pluginMessage.getTag().equals( "BungeeCord" ) )
@Override public void handle(PluginMessage pluginMessage) throws Exception { // TODO: Unregister? if ( pluginMessage.getTag().equals( "REGISTER" ) ) { registerMessages.add( pluginMessage ); } }
/** * Sends the server ID list to the client, or stores it for sending later. * * @param idList The {@link PluginMessage} to send to the client containing * the ID list. * @throws IllegalArgumentException Thrown if the {@link PluginMessage} was * not as expected. */ public void setServerIdList(PluginMessage idList) throws IllegalArgumentException { if ( !idList.getTag().equalsIgnoreCase( ForgeConstants.FML_HANDSHAKE_TAG ) || idList.getData()[0] != 3 ) { throw new IllegalArgumentException( "idList" ); } this.serverIdList = idList; }
/** * Sends the server mod list to the client, or stores it for sending later. * * @param modList The {@link PluginMessage} to send to the client containing * the mod list. * @throws IllegalArgumentException Thrown if the {@link PluginMessage} was * not as expected. */ public void setServerModList(PluginMessage modList) throws IllegalArgumentException { if ( !modList.getTag().equalsIgnoreCase( ForgeConstants.FML_HANDSHAKE_TAG ) || modList.getData()[0] != 2 ) { throw new IllegalArgumentException( "modList" ); } this.serverModList = modList; }
@Override public ForgeServerHandshakeState send(PluginMessage message, UserConnection con) { if ( message.getData()[0] == 3 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) { con.getForgeClientHandler().setServerIdList( message ); return this; } if ( message.getData()[0] == -1 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) // transition to COMPLETE after sending ACK { return this; } if ( message.getTag().equals( ForgeConstants.FORGE_REGISTER ) ) // wait for Forge channel registration { return COMPLETE; } return this; } },
static void logClient(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Client -> Bungee" : "Client <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
static void logServer(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Server -> Bungee" : "Server <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
/** * Handles any {@link PluginMessage} that contains a FML Handshake or Forge * Register. * * @param message The message to handle. * @throws IllegalArgumentException If the wrong packet is sent down. */ public void handle(PluginMessage message) throws IllegalArgumentException { if ( !message.getTag().equalsIgnoreCase( ForgeConstants.FML_HANDSHAKE_TAG ) && !message.getTag().equalsIgnoreCase( ForgeConstants.FORGE_REGISTER ) ) { throw new IllegalArgumentException( "Expecting a Forge REGISTER or FML Handshake packet." ); } message.setAllowExtendedPacket( true ); // FML allows extended packets so this must be enabled ForgeServerHandshakeState prevState = state; packetQueue.add( message ); state = state.send( message, con ); if ( state != prevState ) // send packets { synchronized ( packetQueue ) { while ( !packetQueue.isEmpty() ) { ForgeLogger.logServer( LogDirection.SENDING, prevState.name(), packetQueue.getFirst() ); con.getForgeClientHandler().receive( packetQueue.removeFirst() ); } } } }
@Override public void handle(PluginMessage pluginMessage) throws Exception if ( pluginMessage.getTag().equals( "BungeeCord" ) ) if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 ) if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() ); if ( bungee.getPluginManager().callEvent( event ).isCancelled() ) if ( pluginMessage.getTag().equals( "REGISTER" ) )
/** * 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() ); } } } }