Add multiconnect beta check (#43)

This commit is contained in:
Joseph Burton 2020-08-11 13:49:35 +01:00 committed by creeper123123321
parent 6f5b1ac725
commit c6e0c10b8d

View File

@ -58,9 +58,18 @@ public class VRVersionProvider extends VersionProvider {
Object mcApiInstance = mcApiClass.getMethod("instance").invoke(null);
List<?> protocols = (List<?>) mcApiClass.getMethod("getSupportedProtocols").invoke(mcApiInstance);
Method getValue = iProtocolClass.getMethod("getValue");
Method isMulticonnectBeta;
try {
isMulticonnectBeta = iProtocolClass.getMethod("isMulticonnectBeta");
} catch (NoSuchMethodException e) {
isMulticonnectBeta = null;
}
multiconnectSupportedVersions = new TreeSet<>();
for (Object protocol : protocols) {
multiconnectSupportedVersions.add((Integer) getValue.invoke(protocol));
// Do not use versions with beta multiconnect support, which may have stability issues
if (isMulticonnectBeta == null || !(Boolean) isMulticonnectBeta.invoke(protocol)) {
multiconnectSupportedVersions.add((Integer) getValue.invoke(protocol));
}
}
ViaFabric.JLOGGER.info("ViaFabric will integrate with multiconnect");
}