Skip to content

Commit

Permalink
Ensure players get disconnected with no Java disconnect packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jun 20, 2024
1 parent dd9d5f3 commit 78642db
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ public void connected(ConnectedEvent event) {
@Override
public void disconnected(DisconnectedEvent event) {
loggingIn = false;
loggedIn = false;

String disconnectMessage;
Throwable cause = event.getCause();
Expand Down Expand Up @@ -1036,13 +1035,19 @@ public void disconnected(DisconnectedEvent event) {
} else {
GeyserImpl.getInstance().getLogger().error("An exception occurred: ", cause);
}
// GeyserSession is disconnected via session.disconnect() called indirectly be the server
// This only needs to be "initiated" here when there is an exception, hence the cause clause
GeyserSession.this.disconnect(disconnectMessage);
if (geyser.getConfig().isDebugMode()) {
cause.printStackTrace();
}
}
if ((!GeyserSession.this.closed && GeyserSession.this.loggedIn) || cause != null) {
// GeyserSession is disconnected via session.disconnect() called indirectly be the server
// This needs to be "initiated" here when there is an exception, but also when the Netty connection
// is closed without a disconnect packet - in this case, closed will still be false, but loggedIn
// will also be true as GeyserSession#disconnect will not have been called.
GeyserSession.this.disconnect(disconnectMessage);
}

loggedIn = false;
}

@Override
Expand Down

0 comments on commit 78642db

Please sign in to comment.