diff --git a/MinecraftClient/ChatBots/AntiAFK.cs b/MinecraftClient/ChatBots/AntiAFK.cs index 6c6008b2..e1056f5e 100644 --- a/MinecraftClient/ChatBots/AntiAFK.cs +++ b/MinecraftClient/ChatBots/AntiAFK.cs @@ -26,6 +26,9 @@ namespace MinecraftClient.ChatBots [TomlInlineComment("$config.ChatBot.AntiAfk.Command$")] public string Command = "/ping"; + [TomlInlineComment("$config.ChatBot.AntiAfk.Use_Sneak$")] + public bool Use_Sneak = false; + [TomlInlineComment("$config.ChatBot.AntiAfk.Use_Terrain_Handling$")] public bool Use_Terrain_Handling = false; @@ -81,7 +84,7 @@ namespace MinecraftClient.ChatBots } } - private int count; + private int count, nextrun = 50; private bool previousSneakState = false; private readonly Random random = new(); @@ -108,10 +111,11 @@ namespace MinecraftClient.ChatBots { count++; - if (count == random.Next(Config._DelayMin, Config._DelayMax)) + if (count >= nextrun) { DoAntiAfkStuff(); count = 0; + nextrun = random.Next(Config._DelayMin, Config._DelayMax); } } @@ -149,22 +153,27 @@ namespace MinecraftClient.ChatBots useAlternativeMethod = true; break; } - else moved = MoveToLocation(goal, allowUnsafe: false, allowDirectTeleport: false); + else + { + moved = MoveToLocation(goal, allowUnsafe: false, allowDirectTeleport: false); + } } - if (!useAlternativeMethod) + if (!useAlternativeMethod && Config.Use_Sneak) { // Solve the case when the bot was closed in 1x2, was sneaking, but then he was freed, this will make him not sneak anymore previousSneakState = false; Sneak(false); - return; } } SendText(Config.Command); - Sneak(previousSneakState); - previousSneakState = !previousSneakState; + if (Config.Use_Sneak) + { + Sneak(previousSneakState); + previousSneakState = !previousSneakState; + } count = 0; } diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index e1dd2175..0d006ad3 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -756,6 +756,7 @@ config.ChatBot.Alerts.Log_File=The name of a file where alers logs will be writt 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=The time interval for execution. (in seconds) config.ChatBot.AntiAfk.Command=Command to send to the server. +config.ChatBot.AntiAfk.Use_Sneak=Whether to sneak when sending the command. 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 times can the bot fail trying to move before using the command method. diff --git a/MinecraftClient/Resources/lang/zh-Hans.ini b/MinecraftClient/Resources/lang/zh-Hans.ini index d2cee54b..c04965d1 100644 --- a/MinecraftClient/Resources/lang/zh-Hans.ini +++ b/MinecraftClient/Resources/lang/zh-Hans.ini @@ -756,6 +756,7 @@ config.ChatBot.Alerts.Log_File=日志文件的路径。 config.ChatBot.AntiAfk=定期发送命令,或让机器人随机走动,以避免检测到挂机后被踢出服务器\n # /!\启用前请确保你的服务器规则不禁止反AFK机制!\n# /!\如果启用随机移动,请将机器人围在围栏里,以防走失!(建议尺寸5x5x5) config.ChatBot.AntiAfk.Delay=执行操作的间隔时间。(秒) config.ChatBot.AntiAfk.Command=发送给服务器的指令。 +config.ChatBot.AntiAfk.Use_Sneak=在发送命令时是否蹲下。 config.ChatBot.AntiAfk.Use_Terrain_Handling=启用地形处理,以使机器人能够四处移动。 config.ChatBot.AntiAfk.Walk_Range=机器人可以随机移动的范围(注意:范围越大,速度越慢) config.ChatBot.AntiAfk.Walk_Retries=尝试移动失败几次后在改为发送命令模式。 diff --git a/MinecraftClient/Resources/lang/zh-Hant.ini b/MinecraftClient/Resources/lang/zh-Hant.ini index cdebf7e7..9b53ae72 100644 --- a/MinecraftClient/Resources/lang/zh-Hant.ini +++ b/MinecraftClient/Resources/lang/zh-Hant.ini @@ -756,6 +756,7 @@ config.ChatBot.Alerts.Log_File=日誌檔案的路徑。 config.ChatBot.AntiAfk=定期傳送命令,或讓機器人隨機走動,以避免檢測到掛機後被踢出伺服器\n # /!\啟用前請確保你的伺服器規則不禁止反AFK機制!\n# /!\如果啟用隨機移動,請將機器人圍在圍欄裡,以防走失!(建議尺寸5x5x5) config.ChatBot.AntiAfk.Delay=執行操作的間隔時間。(秒) config.ChatBot.AntiAfk.Command=傳送給伺服器的指令。 +config.ChatBot.AntiAfk.Use_Sneak=在傳送指令時是否蹲下。 config.ChatBot.AntiAfk.Use_Terrain_Handling=啟用地形處理,以使機器人能夠四處移動。 config.ChatBot.AntiAfk.Walk_Range=機器人可以隨機移動的範圍(注意:範圍越大,速度越慢) config.ChatBot.AntiAfk.Walk_Retries=嘗試移動失敗幾次後在改為傳送命令模式。 diff --git a/MinecraftClient/WinAPI/ConsoleIcon.cs b/MinecraftClient/WinAPI/ConsoleIcon.cs index f3f574e1..e2a6bfc0 100644 --- a/MinecraftClient/WinAPI/ConsoleIcon.cs +++ b/MinecraftClient/WinAPI/ConsoleIcon.cs @@ -73,8 +73,6 @@ namespace MinecraftClient.WinAPI { if (ex is HttpRequestException) //Skin not found? Reset to default icon RevertToMCCIcon(); - else - throw ex; } } catch (HttpRequestException) //Skin not found? Reset to default icon