diff --git a/MinecraftClient/ChatBots/AntiAFK.cs b/MinecraftClient/ChatBots/AntiAFK.cs index 5f9234a6..6c6008b2 100644 --- a/MinecraftClient/ChatBots/AntiAFK.cs +++ b/MinecraftClient/ChatBots/AntiAFK.cs @@ -21,7 +21,7 @@ namespace MinecraftClient.ChatBots public bool Enabled = false; [TomlInlineComment("$config.ChatBot.AntiAfk.Delay$")] - public Range Delay = new(600); + public Range Delay = new(60); [TomlInlineComment("$config.ChatBot.AntiAfk.Command$")] public string Command = "/ping"; @@ -35,6 +35,9 @@ namespace MinecraftClient.ChatBots [TomlInlineComment("$config.ChatBot.AntiAfk.Walk_Retries$")] public int Walk_Retries = 20; + [NonSerialized] + public int _DelayMin, _DelayMax; + public void OnSettingUpdate() { if (Walk_Range <= 0) @@ -43,8 +46,11 @@ namespace MinecraftClient.ChatBots LogToConsole(BotName, Translations.TryGet("bot.antiafk.invalid_walk_range")); } - Delay.min = Math.Max(10, Delay.min); - Delay.max = Math.Max(10, Delay.max); + Delay.min = Math.Max(1.0, Delay.min); + Delay.max = Math.Max(1.0, Delay.max); + + Delay.min = Math.Min(int.MaxValue / 10, Delay.min); + Delay.max = Math.Min(int.MaxValue / 10, Delay.max); if (Delay.min > Delay.max) { @@ -52,12 +58,15 @@ namespace MinecraftClient.ChatBots LogToConsole(BotName, Translations.TryGet("bot.antiafk.swapping")); } + _DelayMin = (int)Math.Round(Delay.min * 10); + _DelayMax = (int)Math.Round(Delay.max * 10); + Command ??= string.Empty; } public struct Range { - public int min, max; + public double min, max; public Range(int value) { @@ -99,7 +108,7 @@ namespace MinecraftClient.ChatBots { count++; - if (count == random.Next(Config.Delay.min, Config.Delay.max)) + if (count == random.Next(Config._DelayMin, Config._DelayMax)) { DoAntiAfkStuff(); count = 0; diff --git a/MinecraftClient/ChatBots/AutoDrop.cs b/MinecraftClient/ChatBots/AutoDrop.cs index c962cfaf..a4e3f073 100644 --- a/MinecraftClient/ChatBots/AutoDrop.cs +++ b/MinecraftClient/ChatBots/AutoDrop.cs @@ -22,7 +22,6 @@ namespace MinecraftClient.ChatBots [TomlInlineComment("$config.ChatBot.AutoDrop.Mode$")] public DropMode Mode = DropMode.include; - [TomlInlineComment("$config.ChatBot.AutoDrop.Items$")] public List Items = new() { ItemType.Cobblestone, ItemType.Dirt }; public void OnSettingUpdate() { } diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index 7c1a5c72..91e4b4d3 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -61,8 +61,8 @@ namespace MinecraftClient.ChatBots [TomlPrecedingComment("$config.ChatBot.AutoFishing.Movements$")] public LocationConfig[] Movements = new LocationConfig[] { - new LocationConfig(12.34f, -23.45f), - new LocationConfig(123.45, 64, -654.32, -25.14f, 36.25f), + new LocationConfig(12.34, -23.45), + new LocationConfig(123.45, 64, -654.32, -25.14, 36.25), new LocationConfig(-1245.63, 63.5, 1.2), }; @@ -94,7 +94,7 @@ namespace MinecraftClient.ChatBots public Coordination? XYZ; public Facing? facing; - public LocationConfig(float yaw, float pitch) + public LocationConfig(double yaw, double pitch) { this.XYZ = null; this.facing = new(yaw, pitch); @@ -106,7 +106,7 @@ namespace MinecraftClient.ChatBots this.facing = null; } - public LocationConfig(double x, double y, double z, float yaw, float pitch) + public LocationConfig(double x, double y, double z, double yaw, double pitch) { this.XYZ = new(x, y, z); this.facing = new(yaw, pitch); @@ -124,9 +124,9 @@ namespace MinecraftClient.ChatBots public struct Facing { - public float yaw, pitch; + public double yaw, pitch; - public Facing(float yaw, float pitch) + public Facing(double yaw, double pitch) { this.yaw = yaw; this.pitch = pitch; } @@ -437,7 +437,7 @@ namespace MinecraftClient.ChatBots LocationConfig curConfig = locationList[curLocationIdx]; if (curConfig.facing != null) - (nextYaw, nextPitch) = (curConfig.facing.Value.yaw, curConfig.facing.Value.pitch); + (nextYaw, nextPitch) = ((float)curConfig.facing.Value.yaw, (float)curConfig.facing.Value.pitch); else (nextYaw, nextPitch) = (GetYaw(), GetPitch()); diff --git a/MinecraftClient/ChatBots/AutoRelog.cs b/MinecraftClient/ChatBots/AutoRelog.cs index d47f04f5..71f078ca 100644 --- a/MinecraftClient/ChatBots/AutoRelog.cs +++ b/MinecraftClient/ChatBots/AutoRelog.cs @@ -19,7 +19,7 @@ namespace MinecraftClient.ChatBots public bool Enabled = false; [TomlInlineComment("$config.ChatBot.AutoRelog.Delay$")] - public Range Delay = new(10); + public Range Delay = new(3); [TomlInlineComment("$config.ChatBot.AutoRelog.Retries$")] public int Retries = 3; @@ -30,13 +30,23 @@ namespace MinecraftClient.ChatBots [TomlPrecedingComment("$config.ChatBot.AutoRelog.Kick_Messages$")] public string[] Kick_Messages = new string[] { "Connection has been lost", "Server is restarting", "Server is full", "Too Many people" }; + [NonSerialized] + public int _DelayMin, _DelayMax; + public void OnSettingUpdate() { - Delay.min = Math.Max(1, Delay.min); - Delay.max = Math.Max(1, Delay.max); + Delay.min = Math.Max(0.1, Delay.min); + Delay.max = Math.Max(0.1, Delay.max); + + Delay.min = Math.Min(int.MaxValue / 10, Delay.min); + Delay.max = Math.Min(int.MaxValue / 10, Delay.max); + if (Delay.min > Delay.max) (Delay.min, Delay.max) = (Delay.max, Delay.min); + _DelayMin = (int)Math.Round(Delay.min * 10); + _DelayMax = (int)Math.Round(Delay.max * 10); + if (Retries == -1) Retries = int.MaxValue; @@ -47,7 +57,7 @@ namespace MinecraftClient.ChatBots public struct Range { - public int min, max; + public double min, max; public Range(int value) { @@ -120,7 +130,7 @@ namespace MinecraftClient.ChatBots private void LaunchDelayedReconnection(string? msg) { - int delay = random.Next(Config.Delay.min, Config.Delay.max); + int delay = random.Next(Config._DelayMin, Config._DelayMax); LogDebugToConsoleTranslated(String.IsNullOrEmpty(msg) ? "bot.autoRelog.reconnect_always" : "bot.autoRelog.reconnect", msg); LogToConsoleTranslated("bot.autoRelog.wait", delay); System.Threading.Thread.Sleep(delay * 1000); diff --git a/MinecraftClient/ChatBots/FollowPlayer.cs b/MinecraftClient/ChatBots/FollowPlayer.cs index 37fbe221..c05355d0 100644 --- a/MinecraftClient/ChatBots/FollowPlayer.cs +++ b/MinecraftClient/ChatBots/FollowPlayer.cs @@ -18,7 +18,7 @@ namespace MinecraftClient.ChatBots public bool Enabled = false; [TomlInlineComment("$config.ChatBot.FollowPlayer.Update_Limit$")] - public int Update_Limit = 10; + public double Update_Limit = 1; [TomlInlineComment("$config.ChatBot.FollowPlayer.Stop_At_Distance$")] public double Stop_At_Distance = 3.0; @@ -113,7 +113,7 @@ namespace MinecraftClient.ChatBots public override void OnEntityMove(Entity entity) { - if (_updateCounter < Config.Update_Limit) + if (_updateCounter < (int)(Config.Update_Limit * 10)) return; _updateCounter = 0; diff --git a/MinecraftClient/ChatBots/PlayerListLogger.cs b/MinecraftClient/ChatBots/PlayerListLogger.cs index e1266d92..4d6424ce 100644 --- a/MinecraftClient/ChatBots/PlayerListLogger.cs +++ b/MinecraftClient/ChatBots/PlayerListLogger.cs @@ -23,14 +23,14 @@ namespace MinecraftClient.ChatBots public string File = "playerlog.txt"; [TomlInlineComment("$config.ChatBot.PlayerListLogger.Delay$")] - public int Delay = 600; + public double Delay = 60; public void OnSettingUpdate() { File ??= string.Empty; - if (Delay < 10) - Delay = 10; + if (Delay < 1.0) + Delay = 1.0; } } @@ -39,7 +39,7 @@ namespace MinecraftClient.ChatBots public override void Update() { count++; - if (count == Config.Delay) + if (count == (int)(Config.Delay * 10)) { DateTime now = DateTime.Now; diff --git a/MinecraftClient/Logger/FilteredLogger.cs b/MinecraftClient/Logger/FilteredLogger.cs index 5ad42efc..168e126b 100644 --- a/MinecraftClient/Logger/FilteredLogger.cs +++ b/MinecraftClient/Logger/FilteredLogger.cs @@ -9,9 +9,11 @@ namespace MinecraftClient.Logger protected bool ShouldDisplay(FilterChannel channel, string msg) { + if (Config.Logging.FilterMode == LoggingConfigHealper.LoggingConfig.FilterModeEnum.disable) + return true; + Regex? regexToUse = null; // Convert to bool for XOR later. Whitelist = 0, Blacklist = 1 - bool filterMode = Config.Logging.FilterMode == LoggingConfigHealper.LoggingConfig.FilterModeEnum.blacklist; switch (channel) { case FilterChannel.Chat: @@ -33,7 +35,12 @@ namespace MinecraftClient.Logger { // IsMatch and white/blacklist result can be represented using XOR // e.g. matched(true) ^ blacklist(true) => shouldn't log(false) - return regexToUse.IsMatch(msg) ^ filterMode; + if (Config.Logging.FilterMode == LoggingConfigHealper.LoggingConfig.FilterModeEnum.blacklist) + return !regexToUse.IsMatch(msg); + else if (Config.Logging.FilterMode == LoggingConfigHealper.LoggingConfig.FilterModeEnum.whitelist) + return regexToUse.IsMatch(msg); + else + return true; } else return true; } diff --git a/MinecraftClient/Proxy/ProxyHandler.cs b/MinecraftClient/Proxy/ProxyHandler.cs index 9bbf56eb..8a0e225d 100644 --- a/MinecraftClient/Proxy/ProxyHandler.cs +++ b/MinecraftClient/Proxy/ProxyHandler.cs @@ -17,22 +17,22 @@ namespace MinecraftClient.Proxy [TomlDoNotInlineObject] public class Configs { - [TomlInlineComment("$Config.Proxy.Enabled_Login$")] + [TomlInlineComment("$config.Proxy.Enabled_Login$")] public bool Enabled_Login = false; - [TomlInlineComment("$Config.Proxy.Enabled_Ingame$")] + [TomlInlineComment("$config.Proxy.Enabled_Ingame$")] public bool Enabled_Ingame = false; - [TomlInlineComment("$Config.Proxy.Server$")] + [TomlInlineComment("$config.Proxy.Server$")] public ProxyInfoConfig Server = new("0.0.0.0", 8080); - [TomlInlineComment("$Config.Proxy.Proxy_Type$")] + [TomlInlineComment("$config.Proxy.Proxy_Type$")] public ProxyType Proxy_Type = ProxyType.HTTP; - [TomlInlineComment("$Config.Proxy.Username$")] + [TomlInlineComment("$config.Proxy.Username$")] public string Username = ""; - [TomlInlineComment("$Config.Proxy.Password$")] + [TomlInlineComment("$config.Proxy.Password$")] public string Password = ""; public void OnSettingUpdate() { } diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 3bc150ef..cb617770 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -616,7 +616,7 @@ cmd.follow.already_stopped=Already stopped cmd.follow.stopping=Stopped following! cmd.follow.invalid_name=Invalid or empty player name provided! cmd.follow.invalid_player=The specified player is either not connected out out of the range! -cmd.follow.cant_reach_player=Can\'t reach the player, he is either in chunks that are not loaded, too far away or not reachable by a bot due to obstacles like gaps or water bodies! +cmd.follow.cant_reach_player=Can not reach the player, he is either in chunks that are not loaded, too far away or not reachable by a bot due to obstacles like gaps or water bodies! cmd.follow.already_following=Already following {0}! cmd.follow.switched=Switched to following {0}! cmd.follow.started=Started following {0}! @@ -660,51 +660,51 @@ config.backup.fail=§cFailed to write to backup file {0}§r config.saving=§aThe current setting is saved as {0} # Head -config.Head=Startup Config File\n\n# New to Minecraft Console Client? Check out this document: https://mccteam.github.io/guide/configuration.html\n\n# Want to upgrade to a newer version? See https://github.com/MCCTeam/Minecraft-Console-Client/#download +config.Head=Startup Config File\n# Please do not record extraneous data in this file as it will be overwritten by MCC.\n\n# New to Minecraft Console Client? Check out this document: https://mccteam.github.io/guide/configuration.html\n# Want to upgrade to a newer version? See https://github.com/MCCTeam/Minecraft-Console-Client/#download # Main.General config.Main.General.account=Login=Email or Name. Use "-" as password for offline mode. Leave blank to prompt user on startup. -config.Main.General.login=Server address and port. Host can be filled in with domain name or IP. -config.Main.General.server_info=Account type: mojang OR microsoft. Also affects interactive login in console. -config.Main.General.method=Microsoft Account sign-in method: mcc OR browser. +config.Main.General.login=The address of the game server, "Host" can be filled in with domain name or IP address. (The "Port" field can be deleted, it will be resolved automatically) +config.Main.General.server_info=Account type: "mojang" OR "microsoft". Also affects interactive login in console. +config.Main.General.method=Microsoft Account sign-in method: "mcc" OR "browser". If the login always fails, please try to use the "browser" once. # Main.Advanced config.Main.Advanced=Make sure you understand what each setting does before changing anything! -config.Main.Advanced.language=Fill in with in-game locale code, https://github.com/MCCTeam/Minecraft-Console-Client/discussions/2239 -config.Main.Advanced.internal_cmd_char=Use 'none', 'slash' or 'backslash' -config.Main.Advanced.message_cooldown=Minimum delay in seconds between messages to avoid being kicked for spam. -config.Main.Advanced.bot_owners=Name list or myfile.txt, one name per line. /!\ Server admins can impersonate owners! -config.Main.Advanced.mc_version=Use 'auto' or '1.X.X' values. Allows to skip server info retrieval. -config.Main.Advanced.mc_forge=Use 'auto', 'no' or 'force'. Force-enabling only works for MC 1.13+. -config.Main.Advanced.brand_info=Use 'mcc', 'vanilla', or 'none'. This is how MCC identifies itself to the server. -config.Main.Advanced.chatbot_log_file=Leave empty for no logfile -config.Main.Advanced.private_msgs_cmd_name=Used by RemoteControl bot -config.Main.Advanced.show_system_messages=System messages for server ops -config.Main.Advanced.show_xpbar_messages=Messages displayed above xp bar, set this to false in case of xp bar spam -config.Main.Advanced.show_chat_links=Decode links embedded in chat messages and show them in console -config.Main.Advanced.show_inventory_layout=Show inventory layout as ASCII art in inventory command -config.Main.Advanced.terrain_and_movements=Uses more ram, cpu, bandwidth but allows you to move around -config.Main.Advanced.inventory_handling=Toggle inventory handling (beta) -config.Main.Advanced.entity_handling=Toggle entity handling (beta) -config.Main.Advanced.session_cache=How to retain session tokens. Use 'none', 'memory' or 'disk' -config.Main.Advanced.profilekey_cache=How to retain profile key. Use 'none', 'memory' or 'disk' -config.Main.Advanced.resolve_srv_records=Use 'no', 'fast' (5s timeout), or 'yes'. Required for joining some servers. +config.Main.Advanced.language=Fill in with in-game locale code, check https://github.com/MCCTeam/Minecraft-Console-Client/discussions/2239 +config.Main.Advanced.internal_cmd_char=Use "none", "slash"(/) or "backslash"(\). +config.Main.Advanced.message_cooldown=Controls the minimum interval (in seconds) between sending each message to the server. +config.Main.Advanced.bot_owners=Set the owner of the bot. /!\ Server admins can impersonate owners! +config.Main.Advanced.mc_version=Use "auto" or "1.X.X" values. Allows to skip server info retrieval. +config.Main.Advanced.mc_forge=Use "auto", "no" or "force". Force-enabling only works for MC 1.13+. +config.Main.Advanced.brand_info=Use "mcc", "vanilla", or "none". This is how MCC identifies itself to the server. +config.Main.Advanced.chatbot_log_file=Leave empty for no logfile. +config.Main.Advanced.private_msgs_cmd_name=For remote control of the bot. +config.Main.Advanced.show_system_messages=System messages for server ops. +config.Main.Advanced.show_xpbar_messages=Messages displayed above xp bar, set this to false in case of xp bar spam. +config.Main.Advanced.show_chat_links=Decode links embedded in chat messages and show them in console. +config.Main.Advanced.show_inventory_layout=Show inventory layout as ASCII art in inventory command. +config.Main.Advanced.terrain_and_movements=Uses more ram, cpu, bandwidth but allows you to move around. +config.Main.Advanced.inventory_handling=Toggle inventory handling (beta). +config.Main.Advanced.entity_handling=Toggle entity handling (beta). +config.Main.Advanced.session_cache=How to retain session tokens. Use "none", "memory" or "disk". +config.Main.Advanced.profilekey_cache=How to retain profile key. Use "none", "memory" or "disk". +config.Main.Advanced.resolve_srv_records=Use "no", "fast" (5s timeout), or "yes". Required for joining some servers. config.Main.Advanced.account_list=AccountList: It allows a fast account switching without directly using the credentials\n# Usage examples: "/tell reco Player2", "/connect Player1" config.Main.Advanced.server_list=ServerList: It allows an easier and faster server switching with short aliases instead of full server IP\n# Aliases cannot contain dots or spaces, and the name "localhost" cannot be used as an alias.\n# Usage examples: "/tell connect Server1", "/connect Server2" -config.Main.Advanced.player_head_icon=Only works on Windows XP-8 or Windows 10 with old console -config.Main.Advanced.exit_on_failure=Disable pauses on error, for using MCC in non-interactive scripts -config.Main.Advanced.script_cache=Cache compiled scripts for faster load on low-end devices -config.Main.Advanced.timestamps=Prepend timestamps to chat messages -config.Main.Advanced.auto_respawn=Toggle auto respawn if client player was dead (make sure your spawn point is safe) -config.Main.Advanced.minecraft_realms=Enable support for joining Minecraft Realms worlds -config.Main.Advanced.move_head_while_walking=Enable head movement while walking to avoid anti-cheat triggers -config.Main.Advanced.timeout=Set a custom timeout in seconds (Default: 30). Use only if you know what you're doing. -config.Main.Advanced.enable_emoji=If turned off, the emoji will be replaced with a simpler character (for /chunk status) +config.Main.Advanced.player_head_icon=Only works on Windows XP-8 or Windows 10 with old console. +config.Main.Advanced.exit_on_failure=Whether to exit directly when an error occurs, for using MCC in non-interactive scripts. +config.Main.Advanced.script_cache=Cache compiled scripts for faster load on low-end devices. +config.Main.Advanced.timestamps=Prepend timestamps to chat messages. +config.Main.Advanced.auto_respawn=Toggle auto respawn if client player was dead (make sure your spawn point is safe). +config.Main.Advanced.minecraft_realms=Enable support for joining Minecraft Realms worlds. +config.Main.Advanced.move_head_while_walking=Enable head movement while walking to avoid anti-cheat triggers. +config.Main.Advanced.timeout=Customize the TCP connection timeout with the server. (in seconds) +config.Main.Advanced.enable_emoji=If turned off, the emoji will be replaced with a simpler character (for /chunk status). config.Main.Advanced.movement_speed=A movement speed higher than 2 may be considered cheating. config.Main.Advanced.language.invaild=The language code is invalid. # Signature -config.Signature=Chat settings (affects minecraft 1.19+) +config.Signature=Chat signature related settings (affects minecraft 1.19+) config.Signature.LoginWithSecureProfile=Microsoft accounts only. If disabled, will not be able to sign chat and join servers configured with "enforce-secure-profile=true" config.Signature.SignChat=Whether to sign the chat send from MCC config.Signature.SignMessageInCommand=Whether to sign the messages contained in the commands sent by MCC. For example, the message in "/msg" and "/me" @@ -716,19 +716,19 @@ config.Signature.ShowModifiedChat=Set to true to display messages modified by th config.Signature.ShowIllegalSignedChat=Whether to display chat and messages in commands without legal signatures # Logging -config.Logging=Only affect the messages on console. +config.Logging=This setting affects only the messages in the console. config.Logging.DebugMessages=Please enable this before submitting bug reports. Thanks! -config.Logging.ChatMessages=Show server chat messages -config.Logging.InfoMessages=Informative messages (i.e Most of the message from MCC) -config.Logging.WarningMessages=Show warning messages -config.Logging.ErrorMessages=Show error messages -config.Logging.ChatFilter=Regex for filtering chat message -config.Logging.DebugFilter=Regex for filtering debug message -config.Logging.FilterMode=blacklist OR whitelist. Blacklist hide message match regex. Whitelist show message match regex -config.Logging.LogToFile=Write log messages to file -config.Logging.LogFile=Log file name -config.Logging.PrependTimestamp=Prepend timestamp to messages in log file -config.Logging.SaveColorCodes=Keep color codes in the saved text (§b) +config.Logging.ChatMessages=Show server chat messages. +config.Logging.InfoMessages=Informative messages. (i.e Most of the message from MCC) +config.Logging.WarningMessages=Show warning messages. +config.Logging.ErrorMessages=Show error messages. +config.Logging.ChatFilter=Regex for filtering chat message. +config.Logging.DebugFilter=Regex for filtering debug message. +config.Logging.FilterMode="disable" or "blacklist" OR "whitelist". Blacklist hide message match regex. Whitelist show message match regex. +config.Logging.LogToFile=Write log messages to file. +config.Logging.LogFile=Log file name. +config.Logging.PrependTimestamp=Prepend timestamp to messages in log file. +config.Logging.SaveColorCodes=Keep color codes in the saved text.(look like "§b") # AppVars config.AppVars.Variables=can be used in some other fields as %yourvar%\n# %username% and %serverip% are reserved variables. @@ -737,24 +737,25 @@ config.AppVars.Variables=can be used in some other fields as %yourvar%\n# %usern config.Proxy=Connect to a server via a proxy instead of connecting directly\n# If Mojang session services are blocked on your network, set enabled=login to login using proxy but connect directly to the server\n# If connecting to port 25565 (Minecraft) is blocked on your network, set enabled=true to login & connect using the proxy\n# /!\ Make sure your server rules allow Proxies or VPNs before setting enabled=true, or you may face consequences! config.Proxy.Enabled_Login=Whether to connect to the login server through a proxy. config.Proxy.Enabled_Ingame=Whether to connect to the game server through a proxy. -config.Proxy.Server=Proxy server must allow HTTPS for login, and non-443 ports for playing -config.Proxy.Proxy_Type=Supported types: HTTP, SOCKS4, SOCKS4a, SOCKS5 -config.Proxy.Username=Only required for password-protected proxies -config.Proxy.Password=Only required for password-protected proxies +config.Proxy.Server=Proxy server must allow HTTPS for login, and non-443 ports for playing. +config.Proxy.Proxy_Type=Supported types: "HTTP", "SOCKS4", "SOCKS4a", "SOCKS5". +config.Proxy.Username=Only required for password-protected proxies. +config.Proxy.Password=Only required for password-protected proxies. # ChatFormat config.ChatFormat=MCC does it best to detect chat messages, but some server have unusual chat formats\n# When this happens, you'll need to configure chat format below, see README > 'Detecting chat messages'\n# Do not forget to uncomment (remove '#') these settings if modifying them config.ChatFormat.Builtins=MCC support for common message formats. Set "false" to avoid conflicts with custom formats. +config.ChatFormat.UserDefined=Whether to use the custom regular expressions below for detection. # MCSettings -config.MCSettings=Settings below are sent to the server and only affect server-side things like your skin -config.MCSettings.Enabled=If disabled, settings below are not sent to the server -config.MCSettings.Locale=Use any language implemented in Minecraft -config.MCSettings.RenderDistance=Value range: [0 - 255] -config.MCSettings.Difficulty=MC 1.7- difficulty. peaceful, easy, normal, difficult +config.MCSettings=Settings below are sent to the server and only affect server-side things like your skin. +config.MCSettings.Enabled=If disabled, settings below are not sent to the server. +config.MCSettings.Locale=Use any language implemented in Minecraft. +config.MCSettings.RenderDistance=Value range: [0 - 255]. +config.MCSettings.Difficulty=MC 1.7- difficulty. peaceful, easy, normal, difficult. config.MCSettings.ChatMode=Use 'enabled', 'commands', or 'disabled'. Allows to mute yourself... -config.MCSettings.ChatColors=Allows disabling chat colors server-side -config.MCSettings.MainHand=MC 1.9+ main hand. left or right +config.MCSettings.ChatColors=Allows disabling chat colors server-side. +config.MCSettings.MainHand=MC 1.9+ main hand. left or right. # ChatBot config.ChatBot================================ #\n# Minecraft Console Client Bots #\n# =============================== # @@ -765,28 +766,28 @@ config.ChatBot.Alerts.Beep_Enabled=Play a beep sound when a word is detected in config.ChatBot.Alerts.Trigger_By_Words=Triggers an alert after receiving a specified keyword. config.ChatBot.Alerts.Trigger_By_Rain=Trigger alerts when it rains and when it stops. config.ChatBot.Alerts.Trigger_By_Thunderstorm=Triggers alerts at the beginning and end of thunderstorms. -config.ChatBot.Alerts.Matches_File=List of words/strings to alert you on, e.g. "Yourname" -config.ChatBot.Alerts.Excludes_File=List of words/strings to NOT alert you on, e.g. "" +config.ChatBot.Alerts.Matches_File=List of words/strings to alert you on. +config.ChatBot.Alerts.Excludes_File=List of words/strings to NOT alert you on. config.ChatBot.Alerts.Log_To_File=Log alerts info a file. config.ChatBot.Alerts.Log_File=The name of a file where alers logs will be written. # ChatBot.AntiAFK config.ChatBot.AntiAfk=Send a command on a regular or random basis or make the bot walk around randomly to avoid automatic AFK disconnection\n# /!\ Make sure your server rules do not forbid anti-AFK mechanisms!\n# /!\ Make sure you keep the bot in an enclosure to prevent it wandering off if you're using terrain handling! (Recommended size 5x5x5) -config.ChatBot.AntiAfk.Delay=10 = 1s (Can also be a random number between 2 numbers, example: 50-600) (Default: 600) -config.ChatBot.AntiAfk.Command=Command to send to the server -config.ChatBot.AntiAfk.Use_Terrain_Handling=Use terrain handling to enable the bot to move around +config.ChatBot.AntiAfk.Delay=The time interval for execution. (in seconds) +config.ChatBot.AntiAfk.Command=Command to send to the server. +config.ChatBot.AntiAfk.Use_Terrain_Handling=Use terrain handling to enable the bot to move around. config.ChatBot.AntiAfk.Walk_Range=The range the bot can move around randomly (Note: the bigger the range, the slower the bot will be) -config.ChatBot.AntiAfk.Walk_Retries=How many timec can the bot fail trying to move before using the command method +config.ChatBot.AntiAfk.Walk_Retries=How many times can the bot fail trying to move before using the command method. # ChatBot.AutoAttack config.ChatBot.AutoAttack=Automatically attack hostile mobs around you\n# You need to enable Entity Handling to use this bot\n# /!\ Make sure server rules allow your planned use of AutoAttack\n# /!\ SERVER PLUGINS may consider AutoAttack to be a CHEAT MOD and TAKE ACTION AGAINST YOUR ACCOUNT so DOUBLE CHECK WITH SERVER RULES! -config.ChatBot.AutoAttack.Mode=single or multi. single target one mob per attack. multi target all mobs in range per attack -config.ChatBot.AutoAttack.Priority=health or distance. Only needed when using single mode -config.ChatBot.AutoAttack.Cooldown_Time=How long to wait between each attack. Use auto to let MCC calculate it -config.ChatBot.AutoAttack.Interaction=Possible values: Interact, Attack (default), InteractAt (Interact and Attack) -config.ChatBot.AutoAttack.Attack_Hostile=Allow attacking hostile mobs -config.ChatBot.AutoAttack.Attack_Passive=Allow attacking passive mobs -config.ChatBot.AutoAttack.List_Mode=Wether to treat the entities list as a whitelist or as a blacklist +config.ChatBot.AutoAttack.Mode="single" or "multi". single target one mob per attack. multi target all mobs in range per attack +config.ChatBot.AutoAttack.Priority="health" or "distance". Only needed when using single mode +config.ChatBot.AutoAttack.Cooldown_Time=How long to wait between each attack. Set "Custom = false" to let MCC calculate it. +config.ChatBot.AutoAttack.Interaction=Possible values: "Interact", "Attack" (default), "InteractAt" (Interact and Attack). +config.ChatBot.AutoAttack.Attack_Hostile=Allow attacking hostile mobs. +config.ChatBot.AutoAttack.Attack_Passive=Allow attacking passive mobs. +config.ChatBot.AutoAttack.List_Mode=Wether to treat the entities list as a whitelist or as a blacklist. config.ChatBot.AutoAttack.Entites_List=All entity types can be found here: https://bit.ly/3Rg68lp # ChatBot.AutoCraft @@ -797,8 +798,7 @@ config.ChatBot.AutoCraft.Recipes=Recipes.Name: The name can be whatever you like # ChatBot.AutoDrop config.ChatBot.AutoDrop=Automatically drop items in inventory\n# You need to enable Inventory Handling to use this bot\n# See this file for an up-to-date list of item types you can use with this bot:\n# https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/MinecraftClient/Inventory/ItemType.cs -config.ChatBot.AutoDrop.Mode=include, exclude or everything. Include: drop item IN the list. Exclude: drop item NOT IN the list -config.ChatBot.AutoDrop.Items=separate each item name with a comma ',': "ItemOne", "ItemTwo" +config.ChatBot.AutoDrop.Mode="include", "exclude" or "everything". Include: drop item IN the list. Exclude: drop item NOT IN the list # ChatBot.AutoEat config.ChatBot.AutoEat=Automatically eat food when your Hunger value is low\n# You need to enable Inventory Handling to use this bot @@ -806,7 +806,7 @@ config.ChatBot.AutoEat=Automatically eat food when your Hunger value is low\n# Y # ChatBot.AutoFishing config.ChatBot.AutoFishing=Automatically catch fish using a fishing rod\n# Guide: https://mccteam.github.io/guide/chat-bots.html#auto-fishing\n# /!\ Make sure server rules allow automated farming before using this bot config.ChatBot.AutoFishing.Antidespawn=Keep it as false if you have not changed it before. -config.ChatBot.AutoFishing.Mainhand=Use the main hand or the off hand to hold the rod. +config.ChatBot.AutoFishing.Mainhand=Use the mainhand or the offhand to hold the rod. config.ChatBot.AutoFishing.Auto_Start=Whether to start fishing automatically after entering a world. config.ChatBot.AutoFishing.Cast_Delay=How soon to re-cast after successful fishing. config.ChatBot.AutoFishing.Fishing_Delay=How long after entering the game to start fishing (seconds). @@ -819,12 +819,11 @@ config.ChatBot.AutoFishing.Log_Fish_Bobber=For debugging purposes, you can use t config.ChatBot.AutoFishing.Enable_Move=This allows the player to change position/facing after each fish caught. config.ChatBot.AutoFishing.Movements=It will move in order "1->2->3->4->3->2->1->2->..." and can change position or facing or both each time. It is recommended to change the facing only. - # ChatBot.AutoRelog config.ChatBot.AutoRelog=Automatically relog when disconnected by server, for example because the server is restating\n# Put keywords/strings such as "Server is restarting" in kick messages file to relog when the message is seen\n# /!\ Use ignorekickmessage=true at own risk! Server staff might not appreciate if you auto-relog on manual kicks -config.ChatBot.AutoRelog.Delay=use 10 for 10 seconds, 10-60 for a random delay between 10 and 60 seconds -config.ChatBot.AutoRelog.Retries=retries when failing to relog to the server. use -1 for unlimited retries -config.ChatBot.AutoRelog.Ignore_Kick_Message=when set to true, autorelog will reconnect regardless of kick messages +config.ChatBot.AutoRelog.Delay=The delay time before joining the server. (in seconds) +config.ChatBot.AutoRelog.Retries=Retries when failing to relog to the server. use -1 for unlimited retries. +config.ChatBot.AutoRelog.Ignore_Kick_Message=When set to true, autorelog will reconnect regardless of kick messages. config.ChatBot.AutoRelog.Kick_Messages=If the kickout message matches any of the strings, then autorelog will be triggered. # ChatBot.AutoRespond @@ -836,7 +835,7 @@ config.ChatBot.ChatLog=Logs chat messages in a file on disk. # ChatBot.FollowPlayer config.ChatBot.FollowPlayer=Enabled you to make the bot follow you\n# NOTE: This is an experimental feature, the bot can be slow at times, you need to walk with a normal speed and to sometimes stop for it to be able to keep up with you\n# It's similar to making animals follow you when you're holding food in your hand.\n# This is due to a slow pathfinding algorithm, we're working on getting a better one\n# You can tweak the update limit and find what works best for you. (NOTE: Do not but a very low one, because you might achieve the opposite,\n# this might clog the thread for terain handling) and thus slow the bot even more.\n# /!\ Make sure server rules allow an option like this in the rules of the server before using this bot -config.ChatBot.FollowPlayer.Update_Limit=The rate at which the bot does calculations (10 = 1s) (Default: 5) (You can tweak this if you feel the bot is too slow) +config.ChatBot.FollowPlayer.Update_Limit=The rate at which the bot does calculations (in seconds) (You can tweak this if you feel the bot is too slow) config.ChatBot.FollowPlayer.Stop_At_Distance=Do not follow the player if he is in the range of 3 blocks (prevents the bot from pushing a player in an infinite loop) # ChatBot.HangmanGame @@ -849,20 +848,20 @@ config.ChatBot.Mailer=Relay messages between players and servers, like a mail pl config.ChatBot.Map=Allows you to render maps into .jpg images\n# This is useful for solving captchas which use maps\n# The maps are rendered into Rendered_Maps folder.\n# NOTE:\n# This feature is currently only useful for solving captchas which use maps.\n# If some servers have a very short time for solving captchas, enabe auto_render_on_update and prepare to open the file quickly.\n# On linux you can use FTP to access generated files.\n# In the future it might will be possible to display maps directly in the console with a separate command.\n# /!\ Make sure server rules allow bots to be used on the server, or you risk being punished. config.ChatBot.Map.Should_Resize=Should the map be resized? (Default one is small 128x128) config.ChatBot.Map.Resize_To=The size to resize the map to (Note: the bigger it is, the lower the quallity is) -config.ChatBot.Map.Auto_Render_On_Update=Automatically render the map once it's received or updated from/by the server +config.ChatBot.Map.Auto_Render_On_Update=Automatically render the map once it is received or updated from/by the server config.ChatBot.Map.Delete_All_On_Unload=Delete all rendered maps on unload/reload (Does not delete the images if you exit the client) config.ChatBot.Map.Notify_On_First_Update=Get a notification when you have gotten a map from the server for the first time # ChatBot.PlayerListLogger -config.ChatBot.PlayerListLogger=Log the list of players periodically into a textual file -config.ChatBot.PlayerListLogger.Delay=10 = 1s +config.ChatBot.PlayerListLogger=Log the list of players periodically into a textual file. +config.ChatBot.PlayerListLogger.Delay=(In seconds) # ChatBot.RemoteControl config.ChatBot.RemoteControl=Send MCC console commands to your bot through server PMs (/tell)\n# You need to have ChatFormat working correctly and add yourself in botowners to use the bot\n# /!\ Server admins can spoof PMs (/tellraw, /nick) so enable RemoteControl only if you trust server admins # ChatBot.ReplayCapture config.ChatBot.ReplayCapture=Enable recording of the game (/replay start) and replay it later using the Replay Mod (https://www.replaymod.com/)\n# Please note that due to technical limitations, the client player (you) will not be shown in the replay file\n# /!\ You SHOULD use /replay stop or exit the program gracefully with /quit OR THE REPLAY FILE MAY GET CORRUPT! -config.ChatBot.ReplayCapture.Backup_Interval=How long should replay file be auto-saved, in seconds. Use -1 to disable +config.ChatBot.ReplayCapture.Backup_Interval=How long should replay file be auto-saved, in seconds. Use -1 to disable. # ChatBot.ScriptScheduler config.ChatBot.ScriptScheduler=Schedule commands and scripts to launch on various events such as server join, date/time or time interval\n# See README > 'Using the Script Scheduler' for more info diff --git a/MinecraftClient/Resources/lang/zh-Hans.ini b/MinecraftClient/Resources/lang/zh-Hans.ini index c13d96f1..42938675 100644 --- a/MinecraftClient/Resources/lang/zh-Hans.ini +++ b/MinecraftClient/Resources/lang/zh-Hans.ini @@ -4,8 +4,8 @@ mcc.help_us_translate=帮助我们翻译MCC:{0} mcc.run_with_default_settings=\nMCC正在使用默认配置运行。 mcc.settings_generated=§c配置文件 MinecraftClient.ini 已经生成。 mcc.has_update=§e新版本的MCC已经推出:{0} -mcc.login=账户名: -mcc.login_basic_io=请输入用户名或邮箱。 +mcc.login=登录: +mcc.login_basic_io=请输入。 mcc.password=密码: mcc.password_basic_io=请输入{0}的密码。 mcc.password_hidden=密码:{0} diff --git a/MinecraftClient/Scripting/ChatBot.cs b/MinecraftClient/Scripting/ChatBot.cs index 51f04829..d996af1a 100644 --- a/MinecraftClient/Scripting/ChatBot.cs +++ b/MinecraftClient/Scripting/ChatBot.cs @@ -522,7 +522,7 @@ namespace MinecraftClient text = GetVerbatim(text); //User-defined regex for private chat messages - if (Config.ChatFormat.Private != null) + if (Config.ChatFormat.UserDefined && !string.IsNullOrWhiteSpace(Config.ChatFormat.Private)) { Match regexMatch = new Regex(Config.ChatFormat.Private).Match(text); if (regexMatch.Success && regexMatch.Groups.Count >= 3) @@ -633,7 +633,7 @@ namespace MinecraftClient text = GetVerbatim(text); //User-defined regex for public chat messages - if (Config.ChatFormat.Public != null) + if (Config.ChatFormat.UserDefined && !string.IsNullOrWhiteSpace(Config.ChatFormat.Public)) { Match regexMatch = new Regex(Config.ChatFormat.Public).Match(text); if (regexMatch.Success && regexMatch.Groups.Count >= 3) @@ -736,7 +736,7 @@ namespace MinecraftClient text = GetVerbatim(text); //User-defined regex for teleport requests - if (Config.ChatFormat.TeleportRequest != null) + if (Config.ChatFormat.UserDefined && !string.IsNullOrWhiteSpace(Config.ChatFormat.TeleportRequest)) { Match regexMatch = new Regex(Config.ChatFormat.TeleportRequest).Match(text); if (regexMatch.Success && regexMatch.Groups.Count >= 2) diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index aabc6833..1cd353c9 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -176,14 +176,14 @@ namespace MinecraftClient } bool needUpdate = true; - string newConfigStr = newConfig.ToString(); + byte[] newConfigByte = Encoding.UTF8.GetBytes(newConfig.ToString()); if (File.Exists(filepath)) { try { - string oldConfigStr = File.ReadAllText(filepath); - if (oldConfigStr == newConfigStr) - needUpdate = false; + if (new FileInfo(filepath).Length == newConfigByte.Length) + if (File.ReadAllBytes(filepath).SequenceEqual(newConfigByte)) + needUpdate = false; } catch { } } @@ -205,7 +205,7 @@ namespace MinecraftClient if (backupSuccessed) { - try { File.WriteAllText(filepath, newConfigStr); } + try { File.WriteAllBytes(filepath, newConfigByte); } catch (Exception ex) { ConsoleIO.WriteLineFormatted(Translations.TryGet("config.write.fail", filepath)); @@ -268,14 +268,14 @@ namespace MinecraftClient public class HeadComment { [TomlProperty("Current Version")] - public string CurrentVersion { get; set; } = Program.BuildInfo ?? Program.MCHighestVersion; + public string CurrentVersion { get; set; } = Program.BuildInfo ?? "Development Build"; [TomlProperty("Latest Version")] public string LatestVersion { get; set; } = "Unknown"; public void OnSettingUpdate() { - CurrentVersion = Program.BuildInfo ?? Program.MCHighestVersion; + CurrentVersion = Program.BuildInfo ?? "Development Build"; LatestVersion ??= "Unknown"; } } @@ -373,10 +373,11 @@ namespace MinecraftClient Advanced.MovementSpeed = 1; Advanced.Language = Regex.Replace(Advanced.Language, @"[^-^_^\w^*\d]", string.Empty).Replace('-', '_'); + Advanced.Language = ToLowerIfNeed(Advanced.Language); if (!AvailableLang.Contains(Advanced.Language)) { Advanced.Language = Translations.GetTranslationPriority().Item1; - ConsoleIO.WriteLogLine("[Settings] " + Translations.GetOrNull("config.Main.Advanced.language.invaild") ?? "The language code is invalid."); + ConsoleIO.WriteLogLine("[Settings] " + (Translations.GetOrNull("config.Main.Advanced.language.invaild") ?? "The language code is invalid.")); } if (!string.IsNullOrWhiteSpace(General.Server.Host)) @@ -418,7 +419,7 @@ namespace MinecraftClient public class AdvancedConfig { [TomlInlineComment("$config.Main.Advanced.language$")] - public string Language = "en_GB"; + public string Language = "en_gb"; // [TomlInlineComment("$config.Main.Advanced.console_title$")] public string ConsoleTitle = "%username%@%serverip% - Minecraft Console Client"; @@ -427,7 +428,7 @@ namespace MinecraftClient public InternalCmdCharType InternalCmdChar = InternalCmdCharType.slash; [TomlInlineComment("$config.Main.Advanced.message_cooldown$")] - public int MessageCooldown = 2; + public double MessageCooldown = 1.0; [TomlInlineComment("$config.Main.Advanced.bot_owners$")] public List BotOwners = new() { "Player1", "Player2" }; @@ -657,7 +658,7 @@ namespace MinecraftClient public string DebugFilterRegex = @".*"; [TomlInlineComment("$config.Logging.FilterMode$")] - public FilterModeEnum FilterMode = FilterModeEnum.whitelist; + public FilterModeEnum FilterMode = FilterModeEnum.disable; [TomlInlineComment("$config.Logging.LogToFile$")] public bool LogToFile = false; @@ -673,7 +674,7 @@ namespace MinecraftClient public void OnSettingUpdate() { } - public enum FilterModeEnum { blacklist, whitelist } + public enum FilterModeEnum { disable, blacklist, whitelist } } } @@ -937,6 +938,9 @@ namespace MinecraftClient [TomlInlineComment("$config.ChatFormat.Builtins$")] public bool Builtins = true; + [TomlInlineComment("$config.ChatFormat.UserDefined$")] + public bool UserDefined = false; + public string Public = @"^<([a-zA-Z0-9_]+)> (.+)$"; public string Private = @"^([a-zA-Z0-9_]+) whispers to you: (.+)$"; @@ -961,7 +965,7 @@ namespace MinecraftClient set { ChatBots.Alerts.Config = value; ChatBots.Alerts.Config.OnSettingUpdate(); } } - [TomlPrecedingComment("$config.ChatBot.AntiAFK$")] + [TomlPrecedingComment("$config.ChatBot.AntiAfk$")] public ChatBots.AntiAFK.Configs AntiAFK { get { return ChatBots.AntiAFK.Config; }