Unexpected DisconnectEvent#getLoginStatus() result when disconnected by the backend
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 959
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
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:
The Player#getCurrentServer() is set to null in:
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java, around lines 803-807 and 969-982, and trace the disconnect ordering for client versus backend kicks. Reproduce both cases with DisconnectEvent and compare getCurrentServer() and getLoginStatus(); done means backend kicks report the expected successful-login status without breaking disconnect handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100