mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2025-01-02 18:17:36 +01:00
update viaversion
This commit is contained in:
parent
36097d42da
commit
bbe70b3a7e
@ -10,10 +10,10 @@ plugins {
|
||||
}
|
||||
|
||||
def ENV = System.getenv()
|
||||
def vvVer = "4.0.0-1.17-pre2-SNAPSHOT"
|
||||
def vvVer = "4.0.0-1.17-pre4-SNAPSHOT"
|
||||
|
||||
description = "Client-side and server-side ViaVersion implementation for Fabric"
|
||||
version = "0.4.0+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
|
||||
version = "0.4.1+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
|
||||
logger.lifecycle("Building ViaFabric: $version")
|
||||
|
||||
def getBranch() {
|
||||
|
@ -30,29 +30,32 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|
||||
private int[] multiconnectSupportedVersions = null;
|
||||
|
||||
{
|
||||
multiconnectIntegration();
|
||||
}
|
||||
|
||||
private void multiconnectIntegration() {
|
||||
if (!FabricLoader.getInstance().isModLoaded("multiconnect")) return;
|
||||
try {
|
||||
if (FabricLoader.getInstance().isModLoaded("multiconnect")) {
|
||||
Class<?> mcApiClass = Class.forName("net.earthcomputer.multiconnect.api.MultiConnectAPI");
|
||||
Class<?> iProtocolClass = Class.forName("net.earthcomputer.multiconnect.api.IProtocol");
|
||||
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;
|
||||
}
|
||||
Set<Integer> vers = new TreeSet<>();
|
||||
for (Object protocol : protocols) {
|
||||
// Do not use versions with beta multiconnect support, which may have stability issues
|
||||
if (isMulticonnectBeta == null || !(Boolean) isMulticonnectBeta.invoke(protocol)) {
|
||||
vers.add((Integer) getValue.invoke(protocol));
|
||||
}
|
||||
}
|
||||
multiconnectSupportedVersions = vers.stream().mapToInt(Integer::intValue).toArray();
|
||||
getLogger().info("ViaFabric will integrate with multiconnect");
|
||||
Class<?> mcApiClass = Class.forName("net.earthcomputer.multiconnect.api.MultiConnectAPI");
|
||||
Class<?> iProtocolClass = Class.forName("net.earthcomputer.multiconnect.api.IProtocol");
|
||||
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;
|
||||
}
|
||||
Set<Integer> vers = new TreeSet<>();
|
||||
for (Object protocol : protocols) {
|
||||
// Do not use versions with beta multiconnect support, which may have stability issues
|
||||
if (isMulticonnectBeta == null || !(Boolean) isMulticonnectBeta.invoke(protocol)) {
|
||||
vers.add((Integer) getValue.invoke(protocol));
|
||||
}
|
||||
}
|
||||
multiconnectSupportedVersions = vers.stream().mapToInt(Integer::intValue).toArray();
|
||||
getLogger().info("ViaFabric will integrate with multiconnect");
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException
|
||||
| ClassCastException ignored) {
|
||||
}
|
||||
@ -116,7 +119,7 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|
||||
getLogger().info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector");
|
||||
PacketWrapper newAnswer = PacketWrapper.create(0x00, null, connection);
|
||||
newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion + "}}");
|
||||
newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class, true, true);
|
||||
newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class);
|
||||
throw CancelException.generate();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
minecraft("com.mojang:minecraft:1.17-pre2")
|
||||
mappings("net.fabricmc:yarn:1.17-pre2+build.1:v2")
|
||||
minecraft("com.mojang:minecraft:1.17-pre4")
|
||||
mappings("net.fabricmc:yarn:1.17-pre4+build.1:v2")
|
||||
|
||||
modImplementation("net.fabricmc.fabric-api:fabric-api:0.34.8+1.17")
|
||||
modImplementation("com.terraformersmc:modmenu:2.0.0-beta.5")
|
||||
modImplementation("com.terraformersmc:modmenu:2.0.0-beta.7")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user