Add IP address to client disconnect message. Closes #9603

This commit is contained in:
LexManos committed 2023-07-03 16:54:40 -07:00
1 parent 063546c37d
commit 47a2e137ed
1 file changed
+4 -1
@@ -184,7 +184,10 @@ public class ServerLifecycleHooks
private static void rejectConnection(final Connection manager, ConnectionType type, String message) {
manager.setProtocol(ConnectionProtocol.LOGIN);
LOGGER.info(SERVERHOOKS, "Disconnecting {} connection attempt: {}", type, message);
String ip = "local";
if (manager.getRemoteAddress() != null)
ip = manager.getRemoteAddress().toString();
LOGGER.info(SERVERHOOKS, "[{}] Disconnecting {} connection attempt: {}", ip, type, message);
MutableComponent text = Component.literal(message);
manager.send(new ClientboundLoginDisconnectPacket(text));
manager.disconnect(text);