From 60eef09fddc22ca43ec1112d539420469bdd9916 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 30 Aug 2020 20:59:04 -0400 Subject: [PATCH] Fix coding error that caused players to time out if moving to another server fails Thanks to @Gabik21 for noticing this bug. --- .../proxy/connection/client/ConnectedPlayer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index b96841786..47a258f5a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -430,17 +430,20 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { } KickedFromServerEvent originalEvent = new KickedFromServerEvent(this, rs, kickReason, !kickedFromCurrent, result); - handleKickEvent(originalEvent, friendlyReason); + handleKickEvent(originalEvent, friendlyReason, kickedFromCurrent); } } - private void handleKickEvent(KickedFromServerEvent originalEvent, Component friendlyReason) { + private void handleKickEvent(KickedFromServerEvent originalEvent, Component friendlyReason, + boolean kickedFromCurrent) { server.getEventManager().fire(originalEvent) .thenAcceptAsync(event -> { // There can't be any connection in flight now. connectionInFlight = null; // Make sure we clear the current connected server as the connection is invalid. - connectedServer = null; + if (kickedFromCurrent) { + connectedServer = null; + } if (event.getResult() instanceof DisconnectPlayer) { DisconnectPlayer res = (DisconnectPlayer) event.getResult();