From 78dd3ea17e3bcb386f49a3295cd73171b5ef7245 Mon Sep 17 00:00:00 2001 From: xdavidwu Date: Tue, 16 Aug 2022 00:17:30 +0800 Subject: [PATCH] ConsoleIO: fix timestamp & BasicIO-NoColor (#2076) * ConsoleIO: correct BasicIO-NoColor handling We need color code stripped string in place of original string, not appending to it * ConsoleIO: fix timestamp order Timestamp should come before the string, not after. * ConsoleIO: check BasicIO-NoColor only when BasicIO --- MinecraftClient/ConsoleIO.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/MinecraftClient/ConsoleIO.cs b/MinecraftClient/ConsoleIO.cs index e4d8e372..d8f026c4 100644 --- a/MinecraftClient/ConsoleIO.cs +++ b/MinecraftClient/ConsoleIO.cs @@ -123,32 +123,33 @@ namespace MinecraftClient if (!String.IsNullOrEmpty(str)) { - if (!acceptnewlines) - { - output.Append(str.Replace('\n', ' ')); - } - else - { - output.Append(str); - } - if (displayTimestamp == null) + if (displayTimestamp == null) { displayTimestamp = EnableTimestamps; } - if (displayTimestamp.Value) + if (displayTimestamp.Value) { int hour = DateTime.Now.Hour, minute = DateTime.Now.Minute, second = DateTime.Now.Second; output.Append(String.Format("{0}:{1}:{2} ", hour.ToString("00"), minute.ToString("00"), second.ToString("00"))); } + if (!acceptnewlines) + { + str = str.Replace('\n', ' '); + } if (BasicIO) { if (BasicIO_NoColor) { output.Append(ChatBot.GetVerbatim(str)); } + else + { + output.Append(str); + } Console.WriteLine(output.ToString()); return; } + output.Append(str); ConsoleInteractive.ConsoleWriter.WriteLineFormatted(output.ToString()); } }