mirror of
				https://github.com/MCCTeam/Minecraft-Console-Client
				synced 2025-10-14 21:22:49 +00:00 
			
		
		
		
	legacy color support
This commit is contained in:
		
							parent
							
								
									7900108763
								
							
						
					
					
						commit
						7ee08092d4
					
				
					 14 changed files with 116 additions and 97 deletions
				
			
		
							
								
								
									
										2
									
								
								.github/workflows/build-and-release.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/build-and-release.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -8,7 +8,7 @@ on:
 | 
			
		|||
  
 | 
			
		||||
env:
 | 
			
		||||
  PROJECT: "MinecraftClient"
 | 
			
		||||
  target-version: "net6.0"
 | 
			
		||||
  target-version: "net7.0"
 | 
			
		||||
  compile-flags: "--self-contained=true -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None"
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,8 +26,8 @@ Global
 | 
			
		|||
		HideSolutionNode = FALSE
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(ExtensibilityGlobals) = postSolution
 | 
			
		||||
		RESX_SortFileContentOnSave = True
 | 
			
		||||
		SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
 | 
			
		||||
		RESX_ShowErrorsInErrorList = False
 | 
			
		||||
		SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
 | 
			
		||||
		RESX_SortFileContentOnSave = False
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
EndGlobal
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                }
 | 
			
		||||
                catch (Exception e)
 | 
			
		||||
                {
 | 
			
		||||
                    LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                    LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                    LogDebugToConsole(e);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -233,7 +233,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogDebugToConsole(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogDebugToConsole(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -265,7 +265,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogDebugToConsole(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -291,7 +291,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
 | 
			
		||||
                LogDebugToConsole(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -420,12 +420,12 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                });
 | 
			
		||||
 | 
			
		||||
                IsConnected = true;
 | 
			
		||||
                LogToConsole("§y§l§f" + Translations.bot_DiscordBridge_connected);
 | 
			
		||||
                LogToConsole("§§2§l§f" + Translations.bot_DiscordBridge_connected);
 | 
			
		||||
                await Task.Delay(-1);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_unknown_error);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_unknown_error);
 | 
			
		||||
                LogToConsole(e);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -160,7 +160,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                {
 | 
			
		||||
                    if (!currentArg.Contains(':'))
 | 
			
		||||
                    {
 | 
			
		||||
                        LogToConsole("§x§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg));
 | 
			
		||||
                        LogToConsole("§§6§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg));
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -168,7 +168,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
 | 
			
		||||
                    if (parts.Length != 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        LogToConsole("§x§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg));
 | 
			
		||||
                        LogToConsole("§§6§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg));
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -177,11 +177,11 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                        case "r":
 | 
			
		||||
                        case "radius":
 | 
			
		||||
                            if (!int.TryParse(parts[1], NumberStyles.Any, CultureInfo.CurrentCulture, out radius))
 | 
			
		||||
                                LogToConsole("§x§1§0" + Translations.bot_farmer_invalid_radius);
 | 
			
		||||
                                LogToConsole("§§6§1§0" + Translations.bot_farmer_invalid_radius);
 | 
			
		||||
 | 
			
		||||
                            if (radius <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                LogToConsole("§x§1§0" + Translations.bot_farmer_invalid_radius);
 | 
			
		||||
                                LogToConsole("§§6§1§0" + Translations.bot_farmer_invalid_radius);
 | 
			
		||||
                                radius = 30;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
 | 
			
		||||
                            if (parts[1].Equals("true") || parts[1].Equals("1"))
 | 
			
		||||
                            {
 | 
			
		||||
                                LogToConsole("§x§1§0" + Translations.bot_farmer_warining_force_unsafe);
 | 
			
		||||
                                LogToConsole("§§6§1§0" + Translations.bot_farmer_warining_force_unsafe);
 | 
			
		||||
                                allowUnsafe = true;
 | 
			
		||||
                            }
 | 
			
		||||
                            else allowUnsafe = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
 | 
			
		||||
                            if (parts[1].Equals("true") || parts[1].Equals("1"))
 | 
			
		||||
                            {
 | 
			
		||||
                                LogToConsole("§w§1§f" + Translations.bot_farmer_warining_allow_teleport);
 | 
			
		||||
                                LogToConsole("§§4§1§f" + Translations.bot_farmer_warining_allow_teleport);
 | 
			
		||||
                                allowTeleport = true;
 | 
			
		||||
                            }
 | 
			
		||||
                            else allowTeleport = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -252,9 +252,9 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
 | 
			
		||||
        private void MainPorcess()
 | 
			
		||||
        {
 | 
			
		||||
            LogToConsole("§y§1§f" + Translations.bot_farmer_started);
 | 
			
		||||
            LogToConsole("§y§1§f " + Translations.bot_farmer_crop_type + ": " + cropType);
 | 
			
		||||
            LogToConsole("§y§1§f " + Translations.bot_farmer_radius + ": " + farmingRadius);
 | 
			
		||||
            LogToConsole("§§2§1§f" + Translations.bot_farmer_started);
 | 
			
		||||
            LogToConsole("§§2§1§f " + Translations.bot_farmer_crop_type + ": " + cropType);
 | 
			
		||||
            LogToConsole("§§2§1§f " + Translations.bot_farmer_radius + ": " + farmingRadius);
 | 
			
		||||
 | 
			
		||||
            while (running)
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                }
 | 
			
		||||
                catch (Exception e)
 | 
			
		||||
                {
 | 
			
		||||
                    LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending);
 | 
			
		||||
                    LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_canceled_sending);
 | 
			
		||||
                    LogDebugToConsole(e);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +209,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_canceled_sending);
 | 
			
		||||
                LogDebugToConsole(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending);
 | 
			
		||||
                LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_canceled_sending);
 | 
			
		||||
                LogDebugToConsole(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -254,7 +254,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                }
 | 
			
		||||
 | 
			
		||||
                if (string.IsNullOrEmpty(Config.ChannelId.Trim()))
 | 
			
		||||
                    LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_missing_channel_id);
 | 
			
		||||
                    LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_missing_channel_id);
 | 
			
		||||
 | 
			
		||||
                botClient = new TelegramBotClient(Config.Token.Trim());
 | 
			
		||||
                cancellationToken = new CancellationTokenSource();
 | 
			
		||||
| 
						 | 
				
			
			@ -273,12 +273,12 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                IsConnected = true;
 | 
			
		||||
 | 
			
		||||
                SendMessage($"✅ {Translations.bot_TelegramBridge_connected}");
 | 
			
		||||
                LogToConsole($"§y§l§f{Translations.bot_TelegramBridge_connected}");
 | 
			
		||||
                LogToConsole($"§§2§l§f{Translations.bot_TelegramBridge_connected}");
 | 
			
		||||
 | 
			
		||||
                if (Config.Authorized_Chat_Ids.Length == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    SendMessage($"⚠️ *{Translations.bot_TelegramBridge_missing_authorized_channels}* ⚠️");
 | 
			
		||||
                    LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_missing_authorized_channels}");
 | 
			
		||||
                    LogToConsole($"§§4§l§f{Translations.bot_TelegramBridge_missing_authorized_channels}");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +286,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_unknown_error}");
 | 
			
		||||
                LogToConsole($"§§4§l§f{Translations.bot_TelegramBridge_unknown_error}");
 | 
			
		||||
                LogToConsole(e);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -368,7 +368,7 @@ namespace MinecraftClient.ChatBots
 | 
			
		|||
                _ => exception.ToString()
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            LogToConsole("§w§l§f" + ErrorMessage);
 | 
			
		||||
            LogToConsole("§§4§l§f" + ErrorMessage);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
using System;
 | 
			
		||||
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig;
 | 
			
		||||
using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig;
 | 
			
		||||
 | 
			
		||||
namespace MinecraftClient
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -75,14 +75,37 @@ namespace MinecraftClient
 | 
			
		|||
 | 
			
		||||
        public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground)
 | 
			
		||||
        {
 | 
			
		||||
            return GetColorEscapeCode(R, G, B, foreground, Settings.Config.Main.Advanced.TerminalColorDepth);
 | 
			
		||||
            return GetColorEscapeCode(R, G, B, foreground, Settings.Config.Console.General.ConsoleColorMode);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground, TerminalColorDepthType colorDepth)
 | 
			
		||||
        public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground, ConsoleColorModeType colorDepth)
 | 
			
		||||
        {
 | 
			
		||||
            switch (colorDepth)
 | 
			
		||||
            {
 | 
			
		||||
                case TerminalColorDepthType.bit_4:
 | 
			
		||||
                case ConsoleColorModeType.disable:
 | 
			
		||||
                    return string.Empty;
 | 
			
		||||
 | 
			
		||||
                case ConsoleColorModeType.legacy_4bit:
 | 
			
		||||
                    {
 | 
			
		||||
                        ColorRGBA color = new(R, G, B);
 | 
			
		||||
                        int best_idx = 0;
 | 
			
		||||
                        double min_distance = ColorMap4[0].Item1.Distance(color);
 | 
			
		||||
                        for (int i = 1; i < ColorMap4.Length; ++i)
 | 
			
		||||
                        {
 | 
			
		||||
                            double distance = ColorMap4[i].Item1.Distance(color);
 | 
			
		||||
                            if (distance < min_distance)
 | 
			
		||||
                            {
 | 
			
		||||
                                min_distance = distance;
 | 
			
		||||
                                best_idx = i;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        if (foreground)
 | 
			
		||||
                            return $"§{best_idx:X}";
 | 
			
		||||
                        else
 | 
			
		||||
                            return $"§§{best_idx:X}";
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                case ConsoleColorModeType.vt100_4bit:
 | 
			
		||||
                    {
 | 
			
		||||
                        ColorRGBA color = new(R, G, B);
 | 
			
		||||
                        int best_idx = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -99,7 +122,7 @@ namespace MinecraftClient
 | 
			
		|||
                        return string.Format("\u001b[{0}m", ColorMap4[best_idx].Item2 - (foreground ? 10 : 0));
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                case TerminalColorDepthType.bit_8:
 | 
			
		||||
                case ConsoleColorModeType.vt100_8bit:
 | 
			
		||||
                    {
 | 
			
		||||
                        ColorRGBA color = new(R, G, B);
 | 
			
		||||
                        int R_idx = (int)(R <= 95 ? Math.Round(R / 95.0) : 1 + Math.Round((R - 95.0) / 40.0));
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +149,7 @@ namespace MinecraftClient
 | 
			
		|||
                            return string.Format("\u001B[{0};5;{1}m", (foreground ? 38 : 48), ColorMap8[best_idx].Item2);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                case TerminalColorDepthType.bit_24:
 | 
			
		||||
                case ConsoleColorModeType.vt100_24bit:
 | 
			
		||||
                    return string.Format("\u001B[{0};2;{1};{2};{3}m", (foreground ? 38 : 48), R, G, B);
 | 
			
		||||
 | 
			
		||||
                default:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -203,9 +203,9 @@ namespace MinecraftClient.Commands
 | 
			
		|||
                for (int x = leftMost; x <= rightMost; ++x)
 | 
			
		||||
                {
 | 
			
		||||
                    if (z == current.ChunkZ && x == current.ChunkX)
 | 
			
		||||
                        sb.Append("§z");           // Player Location: background gray
 | 
			
		||||
                        sb.Append("§§7");           // Player Location: background gray
 | 
			
		||||
                    else if (z == markChunkZ && x == markChunkX)
 | 
			
		||||
                        sb.Append("§w");           // Marked chunk: background red
 | 
			
		||||
                        sb.Append("§§4");           // Marked chunk: background red
 | 
			
		||||
 | 
			
		||||
                    ChunkColumn? chunkColumn = world[x, z];
 | 
			
		||||
                    if (chunkColumn == null)
 | 
			
		||||
| 
						 | 
				
			
			@ -216,12 +216,12 @@ namespace MinecraftClient.Commands
 | 
			
		|||
                        sb.Append(chunkStatusStr[1]);
 | 
			
		||||
 | 
			
		||||
                    if ((z == current.ChunkZ && x == current.ChunkX) || (z == markChunkZ && x == markChunkX))
 | 
			
		||||
                        sb.Append("§r");           // Reset background color
 | 
			
		||||
                        sb.Append("§§r");           // Reset background color
 | 
			
		||||
                }
 | 
			
		||||
                sb.Append('\n');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            sb.Append(string.Format(Translations.cmd_chunk_icon, "§z  §r", "§w  §r", chunkStatusStr[0], chunkStatusStr[1], chunkStatusStr[2]));
 | 
			
		||||
            sb.Append(string.Format(Translations.cmd_chunk_icon, "§§7  §§r", "§§4  §§r", chunkStatusStr[0], chunkStatusStr[1], chunkStatusStr[2]));
 | 
			
		||||
            handler.Log.Info(sb.ToString());
 | 
			
		||||
 | 
			
		||||
            return r.SetAndReturn(Status.Done);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ namespace MinecraftClient.Crypto
 | 
			
		|||
{
 | 
			
		||||
    public class AesCfb8Stream : Stream
 | 
			
		||||
    {
 | 
			
		||||
        public static readonly int blockSize = 16;
 | 
			
		||||
        public const int blockSize = 16;
 | 
			
		||||
 | 
			
		||||
        private readonly Aes? Aes = null;
 | 
			
		||||
        private readonly FastAes? FastAes = null;
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ namespace MinecraftClient.Crypto
 | 
			
		|||
            if (inStreamEnded)
 | 
			
		||||
                return 0;
 | 
			
		||||
 | 
			
		||||
            Span<byte> blockOutput = FastAes != null ? stackalloc byte[blockSize] : null;
 | 
			
		||||
            Span<byte> blockOutput = stackalloc byte[blockSize];
 | 
			
		||||
 | 
			
		||||
            byte[] inputBuf = new byte[blockSize + required];
 | 
			
		||||
            Array.Copy(ReadStreamIV, inputBuf, blockSize);
 | 
			
		||||
| 
						 | 
				
			
			@ -135,18 +135,12 @@ namespace MinecraftClient.Crypto
 | 
			
		|||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    OrderablePartitioner<Tuple<int, int>> rangePartitioner = curRead <= 256 ?
 | 
			
		||||
                        Partitioner.Create(readed, processEnd, 32) : Partitioner.Create(readed, processEnd);
 | 
			
		||||
                    Parallel.ForEach(rangePartitioner, (range, loopState) =>
 | 
			
		||||
                    for (int idx = readed; idx < processEnd; idx++)
 | 
			
		||||
                    {
 | 
			
		||||
                        Span<byte> blockOutput = stackalloc byte[blockSize];
 | 
			
		||||
                        for (int idx = range.Item1; idx < range.Item2; idx++)
 | 
			
		||||
                        {
 | 
			
		||||
                            ReadOnlySpan<byte> blockInput = new(inputBuf, idx, blockSize);
 | 
			
		||||
                            Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None);
 | 
			
		||||
                            buffer[outOffset + idx] = (byte)(blockOutput[0] ^ inputBuf[idx + blockSize]);
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                        ReadOnlySpan<byte> blockInput = new(inputBuf, idx, blockSize);
 | 
			
		||||
                        Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None);
 | 
			
		||||
                        buffer[outOffset + idx] = (byte)(blockOutput[0] ^ inputBuf[idx + blockSize]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <TargetFramework>net6.0</TargetFramework>
 | 
			
		||||
    <TargetFramework>net7.0</TargetFramework>
 | 
			
		||||
    <OutputType>Exe</OutputType>
 | 
			
		||||
    <PublishUrl>publish\</PublishUrl>
 | 
			
		||||
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ using MinecraftClient.Scripting;
 | 
			
		|||
using MinecraftClient.WinAPI;
 | 
			
		||||
using Tomlet;
 | 
			
		||||
using static MinecraftClient.Settings;
 | 
			
		||||
using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig;
 | 
			
		||||
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig;
 | 
			
		||||
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -98,9 +99,7 @@ namespace MinecraftClient
 | 
			
		|||
 | 
			
		||||
            //Build information to facilitate processing of bug reports
 | 
			
		||||
            if (BuildInfo != null)
 | 
			
		||||
            {
 | 
			
		||||
                ConsoleIO.WriteLineFormatted("§8" + BuildInfo);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //Debug input ?
 | 
			
		||||
            if (args.Length == 1 && args[0] == "--keyboard-debug")
 | 
			
		||||
| 
						 | 
				
			
			@ -288,7 +287,7 @@ namespace MinecraftClient
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (Config.Main.Advanced.ConsoleTitle != "")
 | 
			
		||||
            if (!string.IsNullOrWhiteSpace(Config.Main.Advanced.ConsoleTitle))
 | 
			
		||||
            {
 | 
			
		||||
                InternalConfig.Username = "New Window";
 | 
			
		||||
                Console.Title = Config.AppVar.ExpandVars(Config.Main.Advanced.ConsoleTitle);
 | 
			
		||||
| 
						 | 
				
			
			@ -319,28 +318,28 @@ namespace MinecraftClient
 | 
			
		|||
                Random random = new();
 | 
			
		||||
                { // Test 8 bit color
 | 
			
		||||
                    StringBuilder sb = new();
 | 
			
		||||
                    sb.Append("[0123456789]: (8bit)[");
 | 
			
		||||
                    sb.Append("[0123456789]: (vt100 8bit)[");
 | 
			
		||||
                    for (int i = 0; i < 10; ++i)
 | 
			
		||||
                    {
 | 
			
		||||
                        sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255),
 | 
			
		||||
                                                                 (byte)random.Next(255),
 | 
			
		||||
                                                                 (byte)random.Next(255),
 | 
			
		||||
                                                                 true,
 | 
			
		||||
                                                                 TerminalColorDepthType.bit_8)).Append(i);
 | 
			
		||||
                                                                 ConsoleColorModeType.vt100_8bit)).Append(i);
 | 
			
		||||
                    }
 | 
			
		||||
                    sb.Append(ColorHelper.GetResetEscapeCode()).Append(']');
 | 
			
		||||
                    ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString()));
 | 
			
		||||
                }
 | 
			
		||||
                { // Test 24 bit color
 | 
			
		||||
                    StringBuilder sb = new();
 | 
			
		||||
                    sb.Append("[0123456789]: (24bit)[");
 | 
			
		||||
                    sb.Append("[0123456789]: (vt100 24bit)[");
 | 
			
		||||
                    for (int i = 0; i < 10; ++i)
 | 
			
		||||
                    {
 | 
			
		||||
                        sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255),
 | 
			
		||||
                                                                 (byte)random.Next(255),
 | 
			
		||||
                                                                 (byte)random.Next(255),
 | 
			
		||||
                                                                 true,
 | 
			
		||||
                                                                 TerminalColorDepthType.bit_24)).Append(i);
 | 
			
		||||
                                                                 ConsoleColorModeType.vt100_24bit)).Append(i);
 | 
			
		||||
                    }
 | 
			
		||||
                    sb.Append(ColorHelper.GetResetEscapeCode()).Append(']');
 | 
			
		||||
                    ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString()));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -119,7 +119,7 @@ namespace MinecraftClient.Protocol.Message
 | 
			
		|||
            if (message.isSystemChat)
 | 
			
		||||
            {
 | 
			
		||||
                if (Config.Signature.MarkSystemMessage)
 | 
			
		||||
                    color = "§z §r ";     // Custom color code §z : Background Gray
 | 
			
		||||
                    color = "§§7 §§r ";     // Background Gray
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -128,18 +128,18 @@ namespace MinecraftClient.Protocol.Message
 | 
			
		|||
                    if (Config.Signature.ShowModifiedChat && message.unsignedContent != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (Config.Signature.MarkModifiedMsg)
 | 
			
		||||
                            color = "§x §r "; // Custom color code §x : Background Yellow
 | 
			
		||||
                            color = "§§6 §§r "; // Background Yellow
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        if (Config.Signature.MarkLegallySignedMsg)
 | 
			
		||||
                            color = "§y §r "; // Custom color code §y : Background Green
 | 
			
		||||
                            color = "§§2 §§r "; // Background Green
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (Config.Signature.MarkIllegallySignedMsg)
 | 
			
		||||
                        color = "§w §r "; // Custom color code §w : Background Red
 | 
			
		||||
                        color = "§§4 §§r "; // Background Red
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return color + text;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1085,7 +1085,8 @@ namespace MinecraftClient {
 | 
			
		|||
        }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///   Looks up a localized string similar to The settings for command completion suggestions..
 | 
			
		||||
        ///   Looks up a localized string similar to The settings for command completion suggestions.
 | 
			
		||||
        ///Custom colors are only available when using "vt100_24bit" color mode..
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal static string Console_CommandSuggestion {
 | 
			
		||||
            get {
 | 
			
		||||
| 
						 | 
				
			
			@ -1112,20 +1113,20 @@ namespace MinecraftClient {
 | 
			
		|||
        }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///   Looks up a localized string similar to If a garbled code like "←[0m" appears on the terminal, you can turn off this..
 | 
			
		||||
        ///   Looks up a localized string similar to Use "disable", "legacy_4bit", "vt100_4bit", "vt100_8bit" or "vt100_24bit". If a garbled code like "←[0m" appears on the terminal, you can try switching to "legacy_4bit" mode, or just disable it..
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal static string Console_Enable_Color {
 | 
			
		||||
        internal static string Console_General_ConsoleColorMode {
 | 
			
		||||
            get {
 | 
			
		||||
                return ResourceManager.GetString("Console.Enable_Color", resourceCulture);
 | 
			
		||||
                return ResourceManager.GetString("Console.General.ConsoleColorMode", resourceCulture);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///   Looks up a localized string similar to You can use "Ctrl+P" to print out the current input and cursor position..
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal static string Console_General_Display_Uesr_Input {
 | 
			
		||||
        internal static string Console_General_Display_Input {
 | 
			
		||||
            get {
 | 
			
		||||
                return ResourceManager.GetString("Console.General.Display_Uesr_Input", resourceCulture);
 | 
			
		||||
                return ResourceManager.GetString("Console.General.Display_Input", resourceCulture);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
| 
						 | 
				
			
			@ -1559,15 +1560,6 @@ namespace MinecraftClient {
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///   Looks up a localized string similar to Use "none", "bit_4", "bit_8" or "bit_24". This can be checked by opening the debug log..
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal static string Main_Advanced_TerminalColorDepth {
 | 
			
		||||
            get {
 | 
			
		||||
                return ResourceManager.GetString("Main.Advanced.TerminalColorDepth", resourceCulture);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///   Looks up a localized string similar to Uses more ram, cpu, bandwidth but allows you to move around..
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -539,7 +539,8 @@ When this happens, you'll need to configure chat format below, see https://mccte
 | 
			
		|||
    <value>Console-related settings.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Console.CommandSuggestion" xml:space="preserve">
 | 
			
		||||
    <value>The settings for command completion suggestions.</value>
 | 
			
		||||
    <value>The settings for command completion suggestions.
 | 
			
		||||
Custom colors are only available when using "vt100_24bit" color mode.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Console.CommandSuggestion.Enable" xml:space="preserve">
 | 
			
		||||
    <value>Whether to display command suggestions in the console.</value>
 | 
			
		||||
| 
						 | 
				
			
			@ -547,10 +548,10 @@ When this happens, you'll need to configure chat format below, see https://mccte
 | 
			
		|||
  <data name="Console.CommandSuggestion.Use_Basic_Arrow" xml:space="preserve">
 | 
			
		||||
    <value>Enable this option if the arrows in the command suggestions are not displayed properly in your terminal.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Console.Enable_Color" xml:space="preserve">
 | 
			
		||||
    <value>If a garbled code like "←[0m" appears on the terminal, you can turn off this.</value>
 | 
			
		||||
  <data name="Console.General.ConsoleColorMode" xml:space="preserve">
 | 
			
		||||
    <value>Use "disable", "legacy_4bit", "vt100_4bit", "vt100_8bit" or "vt100_24bit". If a garbled code like "←[0m" appears on the terminal, you can try switching to "legacy_4bit" mode, or just disable it.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Console.General.Display_Uesr_Input" xml:space="preserve">
 | 
			
		||||
  <data name="Console.General.Display_Input" xml:space="preserve">
 | 
			
		||||
    <value>You can use "Ctrl+P" to print out the current input and cursor position.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Head" xml:space="preserve">
 | 
			
		||||
| 
						 | 
				
			
			@ -701,9 +702,6 @@ Usage examples: "/tell <mybot> connect Server1", "/connect Server2"</value
 | 
			
		|||
  <data name="Main.Advanced.temporary_fix_badpacket" xml:space="preserve">
 | 
			
		||||
    <value>Temporary fix for Badpacket issue on some servers.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Main.Advanced.TerminalColorDepth" xml:space="preserve">
 | 
			
		||||
    <value>Use "none", "bit_4", "bit_8" or "bit_24". This can be checked by opening the debug log.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="Main.Advanced.terrain_and_movements" xml:space="preserve">
 | 
			
		||||
    <value>Uses more ram, cpu, bandwidth but allows you to move around.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -605,9 +605,6 @@ namespace MinecraftClient
 | 
			
		|||
                    [TomlInlineComment("$Main.Advanced.enable_emoji$")]
 | 
			
		||||
                    public bool EnableEmoji = true;
 | 
			
		||||
 | 
			
		||||
                    [TomlInlineComment("$Main.Advanced.TerminalColorDepth$")]
 | 
			
		||||
                    public TerminalColorDepthType TerminalColorDepth = TerminalColorDepthType.bit_24;
 | 
			
		||||
 | 
			
		||||
                    [TomlInlineComment("$Main.Advanced.MinTerminalWidth$")]
 | 
			
		||||
                    public int MinTerminalWidth = 16;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -640,8 +637,6 @@ namespace MinecraftClient
 | 
			
		|||
                    public enum ResolveSrvRecordType { no, fast, yes };
 | 
			
		||||
 | 
			
		||||
                    public enum ForgeConfigType { no, auto, force };
 | 
			
		||||
 | 
			
		||||
                    public enum TerminalColorDepthType { bit_4, bit_8, bit_24 };
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                public struct AccountInfoConfig
 | 
			
		||||
| 
						 | 
				
			
			@ -788,12 +783,26 @@ namespace MinecraftClient
 | 
			
		|||
 | 
			
		||||
                public void OnSettingUpdate()
 | 
			
		||||
                {
 | 
			
		||||
                    ConsoleInteractive.ConsoleWriter.EnableColor = General.Enable_Color;
 | 
			
		||||
                    // Reader
 | 
			
		||||
                    ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Input;
 | 
			
		||||
 | 
			
		||||
                    ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Uesr_Input;
 | 
			
		||||
                    // Writer
 | 
			
		||||
                    ConsoleInteractive.ConsoleWriter.EnableColor = General.ConsoleColorMode != ConsoleColorModeType.disable;
 | 
			
		||||
 | 
			
		||||
                    ConsoleInteractive.ConsoleWriter.UseVT100ColorCode = General.ConsoleColorMode != ConsoleColorModeType.legacy_4bit;
 | 
			
		||||
 | 
			
		||||
                    // Buffer
 | 
			
		||||
                    General.History_Input_Records = 
 | 
			
		||||
                        ConsoleInteractive.ConsoleBuffer.SetBackreadBufferLimit(General.History_Input_Records);
 | 
			
		||||
 | 
			
		||||
                    // Suggestion
 | 
			
		||||
                    if (General.ConsoleColorMode == ConsoleColorModeType.disable)
 | 
			
		||||
                        CommandSuggestion.Enable_Color = false;
 | 
			
		||||
 | 
			
		||||
                    ConsoleInteractive.ConsoleSuggestion.EnableColor = CommandSuggestion.Enable_Color;
 | 
			
		||||
 | 
			
		||||
                    ConsoleInteractive.ConsoleSuggestion.Enable24bitColor = General.ConsoleColorMode == ConsoleColorModeType.vt100_24bit;
 | 
			
		||||
 | 
			
		||||
                    ConsoleInteractive.ConsoleSuggestion.UseBasicArrow = CommandSuggestion.Use_Basic_Arrow;
 | 
			
		||||
 | 
			
		||||
                    CommandSuggestion.Max_Suggestion_Width =
 | 
			
		||||
| 
						 | 
				
			
			@ -802,7 +811,7 @@ namespace MinecraftClient
 | 
			
		|||
                    CommandSuggestion.Max_Displayed_Suggestions =
 | 
			
		||||
                        ConsoleInteractive.ConsoleSuggestion.SetMaxSuggestionCount(CommandSuggestion.Max_Displayed_Suggestions);
 | 
			
		||||
 | 
			
		||||
                    // CommandSuggestion color settings
 | 
			
		||||
                    // Suggestion color settings
 | 
			
		||||
                    {
 | 
			
		||||
                        if (!CheckColorCode(CommandSuggestion.Text_Color))
 | 
			
		||||
                        {
 | 
			
		||||
| 
						 | 
				
			
			@ -872,11 +881,14 @@ namespace MinecraftClient
 | 
			
		|||
                [TomlDoNotInlineObject]
 | 
			
		||||
                public class MainConfig
 | 
			
		||||
                {
 | 
			
		||||
                    [TomlInlineComment("$Console.Enable_Color$")]
 | 
			
		||||
                    public bool Enable_Color = true;
 | 
			
		||||
                    [TomlInlineComment("$Console.General.ConsoleColorMode$")]
 | 
			
		||||
                    public ConsoleColorModeType ConsoleColorMode = ConsoleColorModeType.vt100_24bit;
 | 
			
		||||
 | 
			
		||||
                    [TomlInlineComment("$Console.General.Display_Uesr_Input$")]
 | 
			
		||||
                    public bool Display_Uesr_Input = true;
 | 
			
		||||
                    [TomlInlineComment("$Console.General.Display_Input$")]
 | 
			
		||||
                    public bool Display_Input = true;
 | 
			
		||||
 | 
			
		||||
                    [TomlInlineComment("$Console.General.History_Input_Records$")]
 | 
			
		||||
                    public int History_Input_Records = 32;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                [TomlDoNotInlineObject]
 | 
			
		||||
| 
						 | 
				
			
			@ -885,7 +897,6 @@ namespace MinecraftClient
 | 
			
		|||
                    [TomlInlineComment("$Console.CommandSuggestion.Enable$")]
 | 
			
		||||
                    public bool Enable = true;
 | 
			
		||||
 | 
			
		||||
                    [TomlInlineComment("$Console.Enable_Color$")]
 | 
			
		||||
                    public bool Enable_Color = true;
 | 
			
		||||
 | 
			
		||||
                    [TomlInlineComment("$Console.CommandSuggestion.Use_Basic_Arrow$")]
 | 
			
		||||
| 
						 | 
				
			
			@ -909,6 +920,8 @@ namespace MinecraftClient
 | 
			
		|||
 | 
			
		||||
                    public string Arrow_Symbol_Color = "#d1d5db";
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                public enum ConsoleColorModeType { disable, legacy_4bit, vt100_4bit, vt100_8bit, vt100_24bit };
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue