From 76173e414506f361c5acc60318a16bcede44edbb Mon Sep 17 00:00:00 2001 From: Jacob Allen <26695048+STG-Allen@users.noreply.github.com> Date: Tue, 4 Aug 2020 16:30:17 -0400 Subject: [PATCH] Add PRE_SERVER_JOIN to DisconnectEvent#LoginStatus (#346) --- .../api/event/connection/DisconnectEvent.java | 4 +++- .../proxy/connection/client/ConnectedPlayer.java | 8 ++++++-- 2 files changed, 9 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 85b5fae86..a509d700c 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 @@ -2,6 +2,7 @@ package com.velocitypowered.api.event.connection; import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.CANCELLED_BY_PROXY; import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.CONFLICTING_LOGIN; +import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.PRE_SERVER_JOIN; import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN; import com.google.common.base.Preconditions; @@ -59,6 +60,7 @@ public final class DisconnectEvent { CONFLICTING_LOGIN, CANCELLED_BY_USER, CANCELLED_BY_PROXY, - CANCELLED_BY_USER_BEFORE_COMPLETE + CANCELLED_BY_USER_BEFORE_COMPLETE, + PRE_SERVER_JOIN } } 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 3876ca91c..3dbfdcd6c 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 @@ -695,8 +695,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { DisconnectEvent.LoginStatus status; if (connectedPlayer.isPresent()) { - status = connectedPlayer.get() == this ? LoginStatus.SUCCESSFUL_LOGIN - : LoginStatus.CONFLICTING_LOGIN; + if (!connectedPlayer.get().getCurrentServer().isPresent()) { + status = LoginStatus.PRE_SERVER_JOIN; + } else { + status = connectedPlayer.get() == this ? LoginStatus.SUCCESSFUL_LOGIN + : LoginStatus.CONFLICTING_LOGIN; + } } else { status = connection.isKnownDisconnect() ? LoginStatus.CANCELLED_BY_PROXY : LoginStatus.CANCELLED_BY_USER;