Skip to content

Commit a018304

Browse files
authored
Strip Minecraft Color Codes (§) in BasicIO-NoColor mode (#995)
Strip Minecraft color codes and formatting (§) if in BasicIO mode by using BasicIO-NoColor.
1 parent 43c2b4b commit a018304

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/Other/
99
/.vs/
1010
SessionCache.ini
11+
.*

MinecraftClient/ChatBot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ protected bool PerformInternalCommand(string command, ref string response_msg, D
240240
/// <summary>
241241
/// Remove color codes ("§c") from a text message received from the server
242242
/// </summary>
243-
protected static string GetVerbatim(string text)
243+
public static string GetVerbatim(string text)
244244
{
245245
if ( String.IsNullOrEmpty(text) )
246246
return String.Empty;

MinecraftClient/ConsoleIO.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public static void SetAutoCompleteEngine(IAutoComplete engine)
5555
/// </summary>
5656
public static bool BasicIO = false;
5757

58+
/// <summary>
59+
/// Determines whether not to print color codes in BasicIO mode.
60+
/// </summary>
61+
public static bool BasicIO_NoColor = false;
62+
5863
/// <summary>
5964
/// Determine whether WriteLineFormatted() should prepend lines with timestamps by default.
6065
/// </summary>
@@ -336,6 +341,10 @@ public static void WriteLineFormatted(string str, bool acceptnewlines = true, bo
336341
}
337342
if (BasicIO)
338343
{
344+
if (BasicIO_NoColor)
345+
{
346+
str = ChatBot.GetVerbatim(str);
347+
}
339348
Console.WriteLine(str);
340349
return;
341350
}

MinecraftClient/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ static void Main(string[] args)
5959

6060
//Setup ConsoleIO
6161
ConsoleIO.LogPrefix = "§8[MCC] ";
62-
if (args.Length >= 1 && args[args.Length - 1] == "BasicIO")
62+
if (args.Length >= 1 && args[args.Length - 1] == "BasicIO" || args.Length >= 1 && args[args.Length - 1] == "BasicIO-NoColor")
6363
{
64+
if (args.Length >= 1 && args[args.Length - 1] == "BasicIO-NoColor")
65+
{
66+
ConsoleIO.BasicIO_NoColor = true;
67+
}
6468
ConsoleIO.BasicIO = true;
6569
args = args.Where(o => !Object.ReferenceEquals(o, args[args.Length - 1])).ToArray();
6670
}

0 commit comments

Comments
 (0)