3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 06:30:16 +02:00
This needs some regression testing to ensure this is the right fix.
Dieser Commit ist enthalten in:
Andrew Steinborn 2021-03-12 23:58:35 -05:00
Ursprung 4206457fbc
Commit 517e92a929
2 geänderte Dateien mit 23 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -30,6 +30,7 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
import com.velocitypowered.proxy.util.except.QuietDecoderException;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@ -46,6 +47,7 @@ import javax.crypto.spec.SecretKeySpec;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
/**
* A utility class to make working with the pipeline a little less painful and transparently handles
@ -64,6 +66,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
private final VelocityServer server;
private ConnectionType connectionType = ConnectionTypes.UNDETERMINED;
private boolean knownDisconnect = false;
private boolean disconnected = false;
/**
* Initializes a new {@link MinecraftConnection} instance.
@ -236,12 +239,18 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
this.setAutoReading(false);
channel.eventLoop().schedule(() -> {
knownDisconnect = true;
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
channel.writeAndFlush(msg).addListener((ChannelFutureListener) future -> {
future.channel().close();
this.fireDisconnected();
});
}, 250, TimeUnit.MILLISECONDS);
});
} else {
knownDisconnect = true;
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
channel.writeAndFlush(msg).addListener((ChannelFutureListener) future -> {
future.channel().close();
this.fireDisconnected();
});
}
}
}
@ -261,17 +270,28 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
knownDisconnect = true;
}
channel.close();
this.fireDisconnected();
} else {
channel.eventLoop().execute(() -> {
if (markKnown) {
knownDisconnect = true;
}
channel.close();
this.fireDisconnected();
});
}
}
}
private void fireDisconnected() {
if (!disconnected) {
disconnected = true;
}
if (sessionHandler != null) {
sessionHandler.disconnected();
}
}
public Channel getChannel() {
return channel;
}

Datei anzeigen

@ -117,8 +117,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
resultFuture.completeExceptionally(
new QuietRuntimeException("The connection to the remote server was unexpectedly closed.\n"
+ "This is usually because the remote server does not have BungeeCord IP forwarding "
+ "correctly enabled.\nSee "
+ "https://docs.velocitypowered.com/en/latest/users/player-info-forwarding.html "
+ "correctly enabled.\nSee https://velocitypowered.com/wiki/users/forwarding/ "
+ "for instructions on how to configure player info forwarding correctly.")
);
} else {