#2420: Disable forge support by default

This commit is contained in:
md_5 2018-05-12 08:24:06 +10:00
parent fde2c3fadf
commit e93323ddbc
4 changed files with 61 additions and 48 deletions

View File

@ -268,10 +268,15 @@ public class BungeeCord extends ProxyServer
pluginManager.loadPlugins(); pluginManager.loadPlugins();
config.load(); config.load();
if ( config.isForgeSupport() )
{
registerChannel( ForgeConstants.FML_TAG ); registerChannel( ForgeConstants.FML_TAG );
registerChannel( ForgeConstants.FML_HANDSHAKE_TAG ); registerChannel( ForgeConstants.FML_HANDSHAKE_TAG );
registerChannel( ForgeConstants.FORGE_REGISTER ); 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;
pluginManager.enablePlugins(); pluginManager.enablePlugins();

View File

@ -310,6 +310,8 @@ public class ServerConnector extends PacketHandler
@Override @Override
public void handle(PluginMessage pluginMessage) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{
if ( BungeeCord.getInstance().config.isForgeSupport() )
{ {
if ( pluginMessage.getTag().equals( ForgeConstants.FML_REGISTER ) ) if ( pluginMessage.getTag().equals( ForgeConstants.FML_REGISTER ) )
{ {
@ -346,13 +348,13 @@ public class ServerConnector extends PacketHandler
// We send the message as part of the handler, so don't send it here. // We send the message as part of the handler, so don't send it here.
throw CancelSendSignal.INSTANCE; throw CancelSendSignal.INSTANCE;
} else }
{ }
// We have to forward these to the user, especially with Forge as stuff might break // We have to forward these to the user, especially with Forge as stuff might break
// This includes any REGISTER messages we intercepted earlier. // This includes any REGISTER messages we intercepted earlier.
user.unsafe().sendPacket( pluginMessage ); user.unsafe().sendPacket( pluginMessage );
} }
}
@Override @Override
public String toString() public String toString()

View File

@ -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" ) ) );

View File

@ -188,6 +188,9 @@ public class UpstreamBridge extends PacketHandler
{ {
throw CancelSendSignal.INSTANCE; throw CancelSendSignal.INSTANCE;
} }
if ( BungeeCord.getInstance().config.isForgeSupport() )
{
// Hack around Forge race conditions // Hack around Forge race conditions
if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 ) if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 )
{ {
@ -208,6 +211,7 @@ public class UpstreamBridge extends PacketHandler
// Do this AFTER the mod list, so we get that even if the intial server isn't modded. // Do this AFTER the mod list, so we get that even if the intial server isn't modded.
throw CancelSendSignal.INSTANCE; 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() );
if ( bungee.getPluginManager().callEvent( event ).isCancelled() ) if ( bungee.getPluginManager().callEvent( event ).isCancelled() )