3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Backport 6cc173d to Velocity 1.0.x

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-08-24 14:12:37 -04:00
Ursprung b85f919238
Commit 7cb70973b0

Datei anzeigen

@ -421,6 +421,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
Optional<RegisteredServer> next = getNextServerToTry(rs); Optional<RegisteredServer> next = getNextServerToTry(rs);
result = next.<ServerKickResult>map(RedirectPlayer::create) result = next.<ServerKickResult>map(RedirectPlayer::create)
.orElseGet(() -> DisconnectPlayer.create(friendlyReason)); .orElseGet(() -> DisconnectPlayer.create(friendlyReason));
// Make sure we clear the current connected server as the connection is invalid.
connectedServer = null;
} else { } else {
// If we were kicked by going to another server, the connection should not be in flight // If we were kicked by going to another server, the connection should not be in flight
if (connectionInFlight != null && connectionInFlight.getServer().equals(rs)) { if (connectionInFlight != null && connectionInFlight.getServer().equals(rs)) {
@ -446,10 +448,34 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
} else if (event.getResult() instanceof RedirectPlayer) { } else if (event.getResult() instanceof RedirectPlayer) {
RedirectPlayer res = (RedirectPlayer) event.getResult(); RedirectPlayer res = (RedirectPlayer) event.getResult();
createConnectionRequest(res.getServer()) createConnectionRequest(res.getServer())
.connectWithIndication() .connect()
.whenCompleteAsync((newResult, exception) -> { .whenCompleteAsync((status, throwable) -> {
if (newResult != null && newResult) { if (throwable != null) {
sendMessage(VelocityMessages.MOVED_TO_NEW_SERVER); handleConnectionException(status != null ? status.getAttemptedConnection()
: res.getServer(), throwable, true);
return;
}
switch (status.getStatus()) {
// Impossible/nonsensical cases
case ALREADY_CONNECTED:
case CONNECTION_IN_PROGRESS:
// Fatal case
case CONNECTION_CANCELLED:
disconnect(status.getReason().orElse(friendlyReason));
break;
case SERVER_DISCONNECTED:
Component reason = status.getReason()
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
handleConnectionException(res.getServer(), Disconnect.create(reason),
((Impl) status).isSafe());
break;
case SUCCESS:
sendMessage(VelocityMessages.MOVED_TO_NEW_SERVER);
break;
default:
// The only remaining value is successful (no need to do anything!)
break;
} }
}, minecraftConnection.eventLoop()); }, minecraftConnection.eventLoop());
} else if (event.getResult() instanceof Notify) { } else if (event.getResult() instanceof Notify) {