mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 03:05:49 +01:00
#2420: Disable forge support by default
This commit is contained in:
parent
fde2c3fadf
commit
e93323ddbc
@ -268,9 +268,14 @@ public class BungeeCord extends ProxyServer
|
|||||||
pluginManager.loadPlugins();
|
pluginManager.loadPlugins();
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
registerChannel( ForgeConstants.FML_TAG );
|
if ( config.isForgeSupport() )
|
||||||
registerChannel( ForgeConstants.FML_HANDSHAKE_TAG );
|
{
|
||||||
registerChannel( ForgeConstants.FORGE_REGISTER );
|
registerChannel( ForgeConstants.FML_TAG );
|
||||||
|
registerChannel( ForgeConstants.FML_HANDSHAKE_TAG );
|
||||||
|
registerChannel( ForgeConstants.FORGE_REGISTER );
|
||||||
|
|
||||||
|
getLogger().warning( "MinecraftForge support is currently unmaintained and may have unresolved issues. Please use at your own risk." );
|
||||||
|
}
|
||||||
|
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
|
|
||||||
|
@ -311,47 +311,49 @@ public class ServerConnector extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PluginMessage pluginMessage) throws Exception
|
public void handle(PluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
if ( pluginMessage.getTag().equals( ForgeConstants.FML_REGISTER ) )
|
if ( BungeeCord.getInstance().config.isForgeSupport() )
|
||||||
{
|
{
|
||||||
Set<String> channels = ForgeUtils.readRegisteredChannels( pluginMessage );
|
if ( pluginMessage.getTag().equals( ForgeConstants.FML_REGISTER ) )
|
||||||
boolean isForgeServer = false;
|
|
||||||
for ( String channel : channels )
|
|
||||||
{
|
{
|
||||||
if ( channel.equals( ForgeConstants.FML_HANDSHAKE_TAG ) )
|
Set<String> channels = ForgeUtils.readRegisteredChannels( pluginMessage );
|
||||||
|
boolean isForgeServer = false;
|
||||||
|
for ( String channel : channels )
|
||||||
{
|
{
|
||||||
// If we have a completed handshake and we have been asked to register a FML|HS
|
if ( channel.equals( ForgeConstants.FML_HANDSHAKE_TAG ) )
|
||||||
// packet, let's send the reset packet now. Then, we can continue the message sending.
|
|
||||||
// The handshake will not be complete if we reset this earlier.
|
|
||||||
if ( user.getServer() != null && user.getForgeClientHandler().isHandshakeComplete() )
|
|
||||||
{
|
{
|
||||||
user.getForgeClientHandler().resetHandshake();
|
// If we have a completed handshake and we have been asked to register a FML|HS
|
||||||
}
|
// packet, let's send the reset packet now. Then, we can continue the message sending.
|
||||||
|
// The handshake will not be complete if we reset this earlier.
|
||||||
|
if ( user.getServer() != null && user.getForgeClientHandler().isHandshakeComplete() )
|
||||||
|
{
|
||||||
|
user.getForgeClientHandler().resetHandshake();
|
||||||
|
}
|
||||||
|
|
||||||
isForgeServer = true;
|
isForgeServer = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isForgeServer && !this.handshakeHandler.isServerForge() )
|
||||||
|
{
|
||||||
|
// We now set the server-side handshake handler for the client to this.
|
||||||
|
handshakeHandler.setServerAsForgeServer();
|
||||||
|
user.setForgeServerHandler( handshakeHandler );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isForgeServer && !this.handshakeHandler.isServerForge() )
|
if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) || pluginMessage.getTag().equals( ForgeConstants.FORGE_REGISTER ) )
|
||||||
{
|
{
|
||||||
// We now set the server-side handshake handler for the client to this.
|
this.handshakeHandler.handle( pluginMessage );
|
||||||
handshakeHandler.setServerAsForgeServer();
|
|
||||||
user.setForgeServerHandler( handshakeHandler );
|
// We send the message as part of the handler, so don't send it here.
|
||||||
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) || pluginMessage.getTag().equals( ForgeConstants.FORGE_REGISTER ) )
|
// We have to forward these to the user, especially with Forge as stuff might break
|
||||||
{
|
// This includes any REGISTER messages we intercepted earlier.
|
||||||
this.handshakeHandler.handle( pluginMessage );
|
user.unsafe().sendPacket( pluginMessage );
|
||||||
|
|
||||||
// We send the message as part of the handler, so don't send it here.
|
|
||||||
throw CancelSendSignal.INSTANCE;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// We have to forward these to the user, especially with Forge as stuff might break
|
|
||||||
// This includes any REGISTER messages we intercepted earlier.
|
|
||||||
user.unsafe().sendPacket( pluginMessage );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,6 +58,7 @@ public class Configuration implements ProxyConfig
|
|||||||
private Favicon favicon;
|
private Favicon favicon;
|
||||||
private int compressionThreshold = 256;
|
private int compressionThreshold = 256;
|
||||||
private boolean preventProxyConnections;
|
private boolean preventProxyConnections;
|
||||||
|
private boolean forgeSupport;
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
@ -86,6 +87,7 @@ public class Configuration implements ProxyConfig
|
|||||||
ipForward = adapter.getBoolean( "ip_forward", ipForward );
|
ipForward = adapter.getBoolean( "ip_forward", ipForward );
|
||||||
compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
|
compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
|
||||||
preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections );
|
preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections );
|
||||||
|
forgeSupport = adapter.getBoolean( "forge_support", forgeSupport );
|
||||||
|
|
||||||
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );
|
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );
|
||||||
|
|
||||||
|
@ -188,25 +188,29 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
throw CancelSendSignal.INSTANCE;
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
// Hack around Forge race conditions
|
|
||||||
if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 )
|
|
||||||
{
|
|
||||||
throw CancelSendSignal.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We handle forge handshake messages if forge support is enabled.
|
if ( BungeeCord.getInstance().config.isForgeSupport() )
|
||||||
if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) )
|
|
||||||
{
|
{
|
||||||
// Let our forge client handler deal with this packet.
|
// Hack around Forge race conditions
|
||||||
con.getForgeClientHandler().handle( pluginMessage );
|
if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 )
|
||||||
throw CancelSendSignal.INSTANCE;
|
{
|
||||||
}
|
throw CancelSendSignal.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
if ( con.getServer() != null && !con.getServer().isForgeServer() && pluginMessage.getData().length > Short.MAX_VALUE )
|
// We handle forge handshake messages if forge support is enabled.
|
||||||
{
|
if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) )
|
||||||
// Drop the packet if the server is not a Forge server and the message was > 32kiB (as suggested by @jk-5)
|
{
|
||||||
// Do this AFTER the mod list, so we get that even if the intial server isn't modded.
|
// Let our forge client handler deal with this packet.
|
||||||
throw CancelSendSignal.INSTANCE;
|
con.getForgeClientHandler().handle( pluginMessage );
|
||||||
|
throw CancelSendSignal.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( con.getServer() != null && !con.getServer().isForgeServer() && pluginMessage.getData().length > Short.MAX_VALUE )
|
||||||
|
{
|
||||||
|
// Drop the packet if the server is not a Forge server and the message was > 32kiB (as suggested by @jk-5)
|
||||||
|
// Do this AFTER the mod list, so we get that even if the intial server isn't modded.
|
||||||
|
throw CancelSendSignal.INSTANCE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() );
|
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||||
|
Loading…
Reference in New Issue
Block a user