mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-09-30 04:27:33 +02:00
0.1.15: Fixed multiconnect integration broken in 0.1.13, closes
This commit is contained in:
parent
754bdd855d
commit
c6a9cef362
@ -20,7 +20,7 @@ val branch = if (!travisBranch.isNullOrBlank()) travisBranch else try {
|
||||
"unknown"
|
||||
}
|
||||
|
||||
version = "0.2.14-SNAPSHOT+" + try {
|
||||
version = "0.2.15-SNAPSHOT+" + try {
|
||||
gitVersion() + "-" + branch
|
||||
} catch (e: Exception) {
|
||||
"unknown"
|
||||
|
@ -116,7 +116,7 @@ public class VRVersionProvider extends VersionProvider {
|
||||
boolean blocked = checkAddressBlocked(addr);
|
||||
boolean supported = ProtocolUtils.isSupported(serverVer, info.getProtocolVersion());
|
||||
|
||||
handleMulticonnectPing(connection, info, blocked, supported, serverVer);
|
||||
handleMulticonnectPing(connection, info, blocked, serverVer);
|
||||
|
||||
if (blocked || !supported) serverVer = info.getProtocolVersion();
|
||||
|
||||
@ -132,12 +132,11 @@ public class VRVersionProvider extends VersionProvider {
|
||||
|| isDisabled(((InetSocketAddress) addr).getAddress().getHostName()))));
|
||||
}
|
||||
|
||||
private void handleMulticonnectPing(UserConnection connection, ProtocolInfo info, boolean blocked, boolean supported, int serverVer) throws Exception {
|
||||
private void handleMulticonnectPing(UserConnection connection, ProtocolInfo info, boolean blocked, int serverVer) throws Exception {
|
||||
if (info.getState() == State.STATUS
|
||||
&& info.getProtocolVersion() == -1
|
||||
&& connection.getChannel().pipeline().get(ClientConnection.class).getPacketListener()
|
||||
.getClass().getName().startsWith("net.earthcomputer.multiconnect") // multiconnect version detector
|
||||
&& (supported || blocked)) { // Intercept the connection
|
||||
.getClass().getName().startsWith("net.earthcomputer.multiconnect")) { // Intercept the connection
|
||||
int multiconnectSuggestion = getVersionForMulticonnect(serverVer);
|
||||
if (blocked) multiconnectSuggestion = -1;
|
||||
ViaFabric.JLOGGER.info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector");
|
||||
@ -150,25 +149,23 @@ public class VRVersionProvider extends VersionProvider {
|
||||
|
||||
private int getVersionForMulticonnect(int clientSideVersion) {
|
||||
// https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/providers/VelocityVersionProvider.java
|
||||
// multiconnect supports it
|
||||
int[] compatibleProtocols = multiconnectSupportedVersions;
|
||||
if (Arrays.binarySearch(compatibleProtocols, clientSideVersion) >= 0)
|
||||
return clientSideVersion;
|
||||
|
||||
// Older than multiconnect supports, get the lowest version
|
||||
if (Arrays.binarySearch(compatibleProtocols, clientSideVersion) >= 0) {
|
||||
return clientSideVersion;
|
||||
}
|
||||
|
||||
if (clientSideVersion < compatibleProtocols[0]) {
|
||||
return compatibleProtocols[0];
|
||||
}
|
||||
|
||||
// Loop through all protocols to get the closest protocol id that multiconnect supports (and that viaversion does too)
|
||||
|
||||
// TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work.
|
||||
// This is more of a workaround for snapshot support by multiconnect.
|
||||
for (int i = compatibleProtocols.length - 1; i >= 0; i--) {
|
||||
int protocol = compatibleProtocols[i];
|
||||
if (clientSideVersion > protocol && ProtocolVersion.isRegistered(protocol))
|
||||
if (clientSideVersion > protocol && ProtocolVersion.isRegistered(protocol)) {
|
||||
return protocol;
|
||||
}
|
||||
}
|
||||
|
||||
ViaFabric.JLOGGER.severe("multiconnect integration: Panic, no protocol id found for " + clientSideVersion);
|
||||
return clientSideVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user