From 079b352c97596368762df333999498cf9c126d1f Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 3 Jul 2020 17:48:20 -0400 Subject: [PATCH] Add a new loginstatus for CANCELLED_BY_USER_BEFORE_COMPLETE --- .../api/event/connection/DisconnectEvent.java | 3 ++- .../proxy/connection/client/LoginSessionHandler.java | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java b/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java index 77377e5c4..85b5fae86 100644 --- a/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/connection/DisconnectEvent.java @@ -58,6 +58,7 @@ public final class DisconnectEvent { SUCCESSFUL_LOGIN, CONFLICTING_LOGIN, CANCELLED_BY_USER, - CANCELLED_BY_PROXY + CANCELLED_BY_PROXY, + CANCELLED_BY_USER_BEFORE_COMPLETE } } 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 7483bb076..134919be4 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 @@ -8,6 +8,8 @@ import static com.velocitypowered.proxy.util.EncryptionUtils.decryptRsa; import static com.velocitypowered.proxy.util.EncryptionUtils.generateServerId; import com.google.common.base.Preconditions; +import com.velocitypowered.api.event.connection.DisconnectEvent; +import com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus; import com.velocitypowered.api.event.connection.LoginEvent; import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.connection.PreLoginEvent; @@ -224,13 +226,13 @@ public class LoginSessionHandler implements MinecraftSessionHandler { if (!mcConnection.isClosed()) { // wait for permissions to load, then set the players permission function player.setPermissionFunction(event.createFunction(player)); - finishLogin(player); + completeLoginProtocolPhaseAndInitialize(player); } }, mcConnection.eventLoop()); }); } - private void finishLogin(ConnectedPlayer player) { + private void completeLoginProtocolPhaseAndInitialize(ConnectedPlayer player) { int threshold = server.getConfiguration().getCompressionThreshold(); if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) { mcConnection.write(new SetCompression(threshold)); @@ -253,6 +255,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler { .thenAcceptAsync(event -> { if (mcConnection.isClosed()) { // The player was disconnected + server.getEventManager().fireAndForget(new DisconnectEvent(player, + LoginStatus.CANCELLED_BY_USER_BEFORE_COMPLETE)); return; }