Fix telling newer 1.7 Forge clients that they are outdated. Fixes #1476

* Only check the version of FML if we are running Minecraft 1.7.10 - 1.8 clients are always valid.
* If the version of FML that is reported is 7.10.99.99 - report the Forge version instead.
This commit is contained in:
Daniel Naylor 2015-05-23 11:38:13 +01:00 committed by md_5
parent a3a31fd2dd
commit f3c14cf064
2 changed files with 32 additions and 13 deletions

View File

@ -4,6 +4,7 @@ import java.util.Map;
import net.md_5.bungee.ServerConnector; import net.md_5.bungee.ServerConnector;
import net.md_5.bungee.UserConnection; import net.md_5.bungee.UserConnection;
import net.md_5.bungee.forge.ForgeLogger.LogDirection; import net.md_5.bungee.forge.ForgeLogger.LogDirection;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
/** /**
@ -86,8 +87,10 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler<ForgeClientH
Map<String, String> clientModList = ForgeUtils.readModList( message ); Map<String, String> clientModList = ForgeUtils.readModList( message );
con.getForgeClientHandler().setClientModList( clientModList ); con.getForgeClientHandler().setClientModList( clientModList );
// If the user is running 1.8 or above, we don't need to check the version of FML - it's always an OK version.
if ( con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_8 )
{
// Get the version from the mod list. // Get the version from the mod list.
// TODO: Remove this once Bungee becomes 1.8 only.
int buildNumber = ForgeUtils.getFmlBuildNumber( clientModList ); int buildNumber = ForgeUtils.getFmlBuildNumber( clientModList );
// If we get 0, we're probably using a testing build, so let it though. Otherwise, check the build number. // If we get 0, we're probably using a testing build, so let it though. Otherwise, check the build number.
@ -98,6 +101,7 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler<ForgeClientH
con.getForgeClientHandler().setForgeOutdated( true ); con.getForgeClientHandler().setForgeOutdated( true );
} }
} }
}
return WAITINGSERVERDATA; return WAITINGSERVERDATA;
} }

View File

@ -61,13 +61,28 @@ public class ForgeUtils
{ {
if ( modList.containsKey( "FML" ) ) if ( modList.containsKey( "FML" ) )
{ {
Matcher matcher = ForgeConstants.FML_HANDSHAKE_VERSION_REGEX.matcher( modList.get( "FML" ) ); String fmlVersion = modList.get( "FML" );
// FML's version is hardcoded to this for builds beyond 1405 for 1.7.10 - if we see this, return Forge's build number.
if ( fmlVersion.equals( "7.10.99.99" ) )
{
Matcher matcher = ForgeConstants.FML_HANDSHAKE_VERSION_REGEX.matcher( modList.get( "Forge" ) );
if ( matcher.find() ) if ( matcher.find() )
{ {
// We know from the regex that we have an int. // We know from the regex that we have an int.
return Integer.parseInt( matcher.group( 4 ) ); return Integer.parseInt( matcher.group( 4 ) );
} }
} }
else
{
Matcher matcher = ForgeConstants.FML_HANDSHAKE_VERSION_REGEX.matcher( fmlVersion );
if ( matcher.find() )
{
// We know from the regex that we have an int.
return Integer.parseInt( matcher.group( 4 ) );
}
}
}
return 0; return 0;
} }