/// <summary> /// Write a Minecraft-Formatted string to the standard output, using §c color codes /// </summary> /// <param name="str">String to write</param> /// <param name="acceptnewlines">If false, space are printed instead of newlines</param> public static void WriteLineFormatted(string str, bool acceptnewlines = true, bool Skip = true, bool setToLeft = false) { if (basicIO) { System.Console.WriteLine(str); return; } if (!String.IsNullOrEmpty(str)) { //int hour = DateTime.Now.Hour, minute = DateTime.Now.Minute, second = DateTime.Now.Second; //ConsoleIO.Write(hour.ToString("00") + ':' + minute.ToString("00") + ':' + second.ToString("00") + ' '); if (setToLeft) { System.Console.CursorLeft = 0; } if (!acceptnewlines) { str = str.Replace('\n', ' '); } if (ConsoleIO.basicIO) { ConsoleIO.WriteLine(str); return; } string[] subs = str.Split(new char[] { '§' }); if (subs[0].Length > 0) { ConsoleIO.Write(subs[0], true); } for (int i = 1; i < subs.Length; i++) { if (subs[i].Length > 0) { switch (subs[i][0]) { case '0': System.Console.ForegroundColor = ConsoleColor.Gray; break; //Should be Black but Black is non-readable on a black background case '1': System.Console.ForegroundColor = ConsoleColor.DarkBlue; break; case '2': System.Console.ForegroundColor = ConsoleColor.DarkGreen; break; case '3': System.Console.ForegroundColor = ConsoleColor.DarkCyan; break; case '4': System.Console.ForegroundColor = ConsoleColor.DarkRed; break; case '5': System.Console.ForegroundColor = ConsoleColor.DarkMagenta; break; case '6': System.Console.ForegroundColor = ConsoleColor.DarkYellow; break; case '7': System.Console.ForegroundColor = ConsoleColor.Gray; break; case '8': System.Console.ForegroundColor = ConsoleColor.DarkGray; break; case '9': System.Console.ForegroundColor = ConsoleColor.Blue; break; case 'a': System.Console.ForegroundColor = ConsoleColor.Green; break; case 'b': System.Console.ForegroundColor = ConsoleColor.Cyan; break; case 'c': System.Console.ForegroundColor = ConsoleColor.Red; break; case 'd': System.Console.ForegroundColor = ConsoleColor.Magenta; break; case 'e': System.Console.ForegroundColor = ConsoleColor.Yellow; break; case 'f': System.Console.ForegroundColor = ConsoleColor.White; break; case 'r': System.Console.ForegroundColor = ConsoleColor.White; break; } if (subs[i].Length > 1) { ConsoleIO.Write(subs[i].Substring(1, subs[i].Length - 1), Skip); } } } ConsoleIO.Write("\n", Skip); } System.Console.ForegroundColor = ConsoleColor.Gray; }