-
-
Notifications
You must be signed in to change notification settings - Fork 839
Description
Expected Behavior
The result of DisconnectEvent#getLoginStatus() should be: SUCCESSFUL_LOGIN
Actual Behavior
When disconnecting using the Minecraft client, the result of DisconnectEvent#getLoginStatus() is:
SUCCESSFUL_LOGIN
When disconnecting using the backend console /kick <player>, the result of DisconnectEvent#getLoginStatus() is:
PRE_SERVER_JOIN
Steps to Reproduce
- Listen to the DisconnectEvent event
@Subscribe
public void onDisconnected(DisconnectEvent event) {
this.logger.info("Current Server: " + event.getPlayer().getCurrentServer());
this.logger.info("Login Status: " + event.getLoginStatus());
}- Log in to the server and disconnect using the Minecraft client (in-game).
- Log in to the server and disconnect the client via the backend with Paper.
kick <player> - Compare the console outputs from steps 2 and 3:
Disconnection by the Minecraft Client (step 2)
[11:55:14 INFO]: [server connection] NickUC -> lobby has disconnected
[11:55:14 INFO] [com.nickuc.test.velocity.VelocityPlugin]: Current Server: Optional[[server connection] NickUC -> lobby]
[11:55:14 INFO] [com.nickuc.test.velocity.VelocityPlugin]: Login Status: SUCCESSFUL_LOGIN
Disconnection by the Backend (step 3)
[11:55:32 INFO]: [server connection] NickUC -> lobby has disconnected
[11:55:32 INFO]: [connected player] NickUC (/[XXXX:XXXX:XXXX:XXXX]:60006) has disconnected: Você foi expulso de lobby:
[11:55:32 INFO] [com.nickuc.test.velocity.VelocityPlugin]: Current Server: Optional.empty
[11:55:32 INFO] [com.nickuc.test.velocity.VelocityPlugin]: Login Status: PRE_SERVER_JOIN
Plugin List
Plugins: velocity, test_plugin
Velocity Version
Velocity 3.4.0-SNAPSHOT (git-8f65a814-b558)
Additional Information
From what I've discovered, this behavior occurs because Player#getCurrentServer() is empty when calling DisconnectEvent in:
Velocity/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java
Lines 969 to 982 in 8f65a81
| DisconnectEvent.LoginStatus status; | |
| if (connectedPlayer.isPresent()) { | |
| if (connectedPlayer.get().getCurrentServer().isEmpty()) { | |
| 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; | |
| } | |
| DisconnectEvent event = new DisconnectEvent(this, status); |
The Player#getCurrentServer() is set to null in:
Velocity/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java
Lines 803 to 807 in 8f65a81
| // Make sure we clear the current connected server as the connection is invalid. | |
| VelocityServerConnection previousConnection = connectedServer; | |
| if (kickedFromCurrent) { | |
| connectedServer = null; | |
| } |
I confirmed that the cause of the problem is in the code above. I commented out the line connectedServer = null and the problem was solved.
I don't know anything about Velocity's internal API, so I have no idea how to solve it.
I am using the default Velocity configuration.