mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-18 15:47:46 +01:00
Fixed version auto detector .write() warn, fixed multiconnect integration behaviour: now checks if suggested version will be supported by ViaFabric
This commit is contained in:
parent
bec45c4dbd
commit
c25b09355c
@ -30,6 +30,7 @@ import com.github.creeper123123321.viafabric.service.ProtocolAutoDetector;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
@ -53,11 +54,13 @@ public class ProtocolDetectionHandler extends ChannelDuplexHandler {
|
||||
ViaFabric.JLOGGER.warning("Timeout for protocol auto-detection in "
|
||||
+ ctx.channel().remoteAddress() + " server");
|
||||
hold = false;
|
||||
drainQueue(ctx);
|
||||
ctx.pipeline().remove(this);
|
||||
}, 10, TimeUnit.SECONDS);
|
||||
ProtocolAutoDetector.SERVER_VER.get(((InetSocketAddress) ctx.channel().remoteAddress()))
|
||||
.whenComplete((obj, ex) -> {
|
||||
hold = false;
|
||||
drainQueue(ctx);
|
||||
ctx.pipeline().remove(this);
|
||||
timeoutRun.cancel(false);
|
||||
});
|
||||
@ -97,7 +100,8 @@ public class ProtocolDetectionHandler extends ChannelDuplexHandler {
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
drainQueue(ctx);
|
||||
queuedMessages.forEach(ReferenceCountUtil::release);
|
||||
queuedMessages.clear();
|
||||
super.handlerRemoved(ctx);
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ public class VRVersionProvider extends VersionProvider {
|
||||
if (info.getState() == State.STATUS
|
||||
&& info.getProtocolVersion() == -1
|
||||
&& connection.getChannel().pipeline().get(ClientConnection.class).getPacketListener()
|
||||
.getClass().getName().startsWith("net.earthcomputer.multiconnect")) { // Intercept the connection
|
||||
int multiconnectSuggestion = getVersionForMulticonnect(serverVer);
|
||||
if (blocked) multiconnectSuggestion = -1;
|
||||
.getClass().getName().startsWith("net.earthcomputer.multiconnect")
|
||||
&& (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection
|
||||
int multiconnectSuggestion = blocked ? -1 : getVersionForMulticonnect(serverVer);
|
||||
ViaFabric.JLOGGER.info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector");
|
||||
PacketWrapper newAnswer = new PacketWrapper(0x00, null, connection);
|
||||
newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion + "}}");
|
||||
|
Loading…
Reference in New Issue
Block a user