From d1473ed938191f375d5bebdf2b62558d9cbe3eba Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sat, 17 Nov 2018 00:04:44 -0500 Subject: [PATCH] Move registration to be performed earlier. --- .../proxy/connection/client/LoginSessionHandler.java | 11 ++++++----- .../proxy/connection/client/StatusSessionHandler.java | 5 ++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java index b23fec1ce..725415859 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java @@ -40,6 +40,7 @@ import java.security.GeneralSecurityException; import java.security.KeyPair; import java.util.Arrays; import java.util.Optional; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadLocalRandom; import net.kyori.text.Component; import org.apache.logging.log4j.LogManager; @@ -228,6 +229,11 @@ public class LoginSessionHandler implements MinecraftSessionHandler { apiInbound.getVirtualHost().orElse(null)); this.connectedPlayer = player; + if (!server.registerConnection(player)) { + player.disconnect(VelocityMessages.ALREADY_CONNECTED); + return CompletableFuture.completedFuture(null); + } + return server.getEventManager() .fire(new PermissionsSetupEvent(player, ConnectedPlayer.DEFAULT_PERMISSIONS)) .thenCompose(event -> { @@ -261,11 +267,6 @@ public class LoginSessionHandler implements MinecraftSessionHandler { return; } - if (!server.registerConnection(player)) { - player.disconnect(VelocityMessages.ALREADY_CONNECTED); - return; - } - int threshold = server.getConfiguration().getCompressionThreshold(); if (threshold >= 0) { inbound.write(new SetCompression(threshold)); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java index d726d0124..d60615289 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java @@ -38,9 +38,8 @@ public class StatusSessionHandler implements MinecraftSessionHandler { public boolean handle(StatusRequest packet) { VelocityConfiguration configuration = server.getConfiguration(); - int shownVersion = ProtocolConstants.isSupported(connection.getProtocolVersion()) ? connection - .getProtocolVersion() : - ProtocolConstants.MAXIMUM_GENERIC_VERSION; + int shownVersion = ProtocolConstants.isSupported(connection.getProtocolVersion()) + ? connection.getProtocolVersion() : ProtocolConstants.MAXIMUM_GENERIC_VERSION; ServerPing initialPing = new ServerPing( new ServerPing.Version(shownVersion, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),