diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/network/client/NettyClient.kt b/src/main/java/de/bixilon/minosoft/protocol/network/network/client/NettyClient.kt index edfc06cf4..14fdc05bd 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/network/client/NettyClient.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/network/network/client/NettyClient.kt @@ -51,7 +51,8 @@ import javax.crypto.Cipher class NettyClient( val connection: Connection, ) : SimpleChannelInboundHandler() { - private var errorReported = connection is StatusConnection // dont report errors in status + private var errorReported = false // dont report errors in status + private val reportErrors: Boolean get() = connection is PlayConnection && !errorReported var connected by watched(false) private set var state by watched(ProtocolStates.HANDSHAKING) @@ -104,7 +105,12 @@ class NettyClient( .channel(channelClass) .handler(NetworkPipeline(this)) - bootstrap.connect(address.hostname, address.port).sync() + val future = bootstrap.connect(address.hostname, address.port) + future.addListener { + if (!it.isSuccess) { + handleError(it.cause()) + } + } } fun setupEncryption(encrypt: Cipher, decrypt: Cipher) { @@ -175,11 +181,14 @@ class NettyClient( } else if (cause is EncoderException) { cause = error.cause ?: cause } - Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN) { cause } + if (connection !is StatusConnection) { + Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN) { cause } + } + connection.error = cause if (cause !is NetworkException || cause is CriticalNetworkException) { - if (!errorReported) { + if (reportErrors) { cause.report() - errorReported = false + errorReported = true } disconnect() return diff --git a/src/main/java/de/bixilon/minosoft/util/logging/Log.kt b/src/main/java/de/bixilon/minosoft/util/logging/Log.kt index 7f8e5f668..dce8c10c2 100644 --- a/src/main/java/de/bixilon/minosoft/util/logging/Log.kt +++ b/src/main/java/de/bixilon/minosoft/util/logging/Log.kt @@ -81,7 +81,6 @@ object Log { if (RunConfiguration.LOG_COLOR_MESSAGE) { messageToSend.message.applyDefaultColor(messageColor) } - message += messageToSend.message val stream = if (messageToSend.logMessageType.error) { SYSTEM_ERR_STREAM @@ -89,7 +88,10 @@ object Log { SYSTEM_OUT_STREAM } - stream.println(message.ansiColoredMessage) + val prefix = message.ansiColoredMessage.removeSuffix("\u001b[0m") // reset suffix + for (line in messageToSend.message.ansiColoredMessage.lines()) { + stream.println(prefix + line) + } if (StaticConfiguration.SHOW_LOG_MESSAGES_IN_CHAT) { val cliConnection = CLI.getCurrentConnection()