Skip to content

Commit

Permalink
Avoid unclear disconnect messages when e.g. key verification failed
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris committed Nov 1, 2024
1 parent c2fd9c7 commit b094a1d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ private boolean checkAndHandleLogin(Object packet) {
if (packet instanceof ServerboundHelloPacket) {
String kickMessage = getKickMessage();
if (kickMessage != null) {
networkManager.disconnect(Component.nullToEmpty(kickMessage));
Component message = Component.nullToEmpty(kickMessage);
// If possible, disconnect using the "proper" packet listener; otherwise there's no proper disconnect message
if (networkManager.getPacketListener() instanceof ServerLoginPacketListenerImpl loginPacketListener) {
loginPacketListener.disconnect(message);
} else {
networkManager.disconnect(message);
}
return true;
}

Expand Down

0 comments on commit b094a1d

Please sign in to comment.