From 432d570474033afb315eec23cdba9992b7e5ca35 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 10 Mar 2019 14:11:24 -0400 Subject: [PATCH] Allow fallback to other server connections in the event of an exception. Also removes some debugging code. --- .../main/java/com/velocitypowered/proxy/VelocityServer.java | 2 -- .../proxy/connection/backend/BackendPlaySessionHandler.java | 4 +++- .../proxy/connection/client/ConnectedPlayer.java | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 9b126041d..4e73dd073 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -8,7 +8,6 @@ import com.google.gson.GsonBuilder; import com.velocitypowered.api.event.EventManager; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; import com.velocitypowered.api.event.proxy.ProxyReloadEvent; -import com.velocitypowered.api.event.proxy.ProxyShutdownEvent; import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.PluginManager; import com.velocitypowered.api.proxy.Player; @@ -50,7 +49,6 @@ import java.nio.file.Paths; import java.security.KeyPair; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Locale; import java.util.Map; import java.util.Objects; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index 354933773..1a3b3b817 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -31,6 +31,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { private final VelocityServer server; private final VelocityServerConnection serverConn; private final ClientPlaySessionHandler playerSessionHandler; + private boolean exceptionTriggered = false; BackendPlaySessionHandler(VelocityServer server, VelocityServerConnection serverConn) { this.server = server; @@ -167,6 +168,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { @Override public void exception(Throwable throwable) { + exceptionTriggered = true; serverConn.getPlayer().handleConnectionException(serverConn.getServer(), throwable); } @@ -177,7 +179,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { @Override public void disconnected() { serverConn.getServer().removePlayer(serverConn.getPlayer()); - if (!serverConn.isGracefulDisconnect()) { + if (!serverConn.isGracefulDisconnect() && !exceptionTriggered) { serverConn.getPlayer().disconnect(ConnectionMessages.UNEXPECTED_DISCONNECT); } } 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 40f9273e6..5045a2ee6 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 @@ -667,8 +667,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { return; } - System.out.println(status); - switch (status.getStatus()) { case ALREADY_CONNECTED: sendMessage(ConnectionMessages.ALREADY_CONNECTED);