From 2b53d144618f4659d69dc075fc30f5291cf34be4 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 29 Oct 2018 02:58:29 -0400 Subject: [PATCH] Simplify and fix bug in setConnectedServer() Also, while I'm here, fix a typo from a recent PR. --- .../velocitypowered/proxy/config/AnnotatedConfig.java | 2 +- .../proxy/config/VelocityConfiguration.java | 4 ++-- .../proxy/connection/client/ConnectedPlayer.java | 9 +-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/config/AnnotatedConfig.java b/proxy/src/main/java/com/velocitypowered/proxy/config/AnnotatedConfig.java index 2d5ea5932..61f963c26 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/config/AnnotatedConfig.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/config/AnnotatedConfig.java @@ -211,7 +211,7 @@ public abstract class AnnotatedConfig { return key; } - protected static String unesacpeKeyIfNeeded(String key) { + protected static String unescapeKeyIfNeeded(String key) { int lastIndex; if (key.indexOf('"') == 0 && (lastIndex = key.lastIndexOf('"')) == (key.length() - 1)) { return key.substring(1, lastIndex); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java index 7316f45b9..579783e72 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java @@ -487,9 +487,9 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi for (Map.Entry entry : toml.entrySet()) { if (entry.getValue() instanceof String) { forcedHosts - .put(unesacpeKeyIfNeeded(entry.getKey()), ImmutableList.of((String) entry.getValue())); + .put(unescapeKeyIfNeeded(entry.getKey()), ImmutableList.of((String) entry.getValue())); } else if (entry.getValue() instanceof List) { - forcedHosts.put(unesacpeKeyIfNeeded(entry.getKey()), + forcedHosts.put(unescapeKeyIfNeeded(entry.getKey()), ImmutableList.copyOf((List) entry.getValue())); } else { throw new IllegalStateException( 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 71f13b705..866cd8a72 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 @@ -444,16 +444,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { } public void setConnectedServer(@Nullable VelocityServerConnection serverConnection) { - VelocityServerConnection oldConnection = this.connectedServer; this.connectedServer = serverConnection; + this.tryIndex = 0; // reset since we got connected to a server - if (serverConnection == null) { - return; - } - if (oldConnection != null && !serverConnection.getServerInfo() - .equals(oldConnection.getServerInfo())) { - this.tryIndex = 0; - } if (serverConnection == connectionInFlight) { connectionInFlight = null; }