From d222d5f68308dc4470052ad28b0faeeaec0b7367 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Wed, 12 Oct 2022 13:03:57 +0800 Subject: [PATCH] Fix AutoRelog --- MinecraftClient/ChatBots/AutoRelog.cs | 6 +++--- MinecraftClient/ChatBots/FollowPlayer.cs | 2 +- MinecraftClient/ChatBots/ReplayCapture.cs | 6 +++--- MinecraftClient/Resources/lang/de.ini | 2 +- MinecraftClient/Resources/lang/en.ini | 2 +- MinecraftClient/Resources/lang/fr.ini | 2 +- MinecraftClient/Resources/lang/ru.ini | 2 +- MinecraftClient/Resources/lang/vi.ini | 2 +- MinecraftClient/Resources/lang/zh-Hans.ini | 4 ++-- MinecraftClient/Resources/lang/zh-Hant.ini | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/MinecraftClient/ChatBots/AutoRelog.cs b/MinecraftClient/ChatBots/AutoRelog.cs index ba16264a..a62dbd8a 100644 --- a/MinecraftClient/ChatBots/AutoRelog.cs +++ b/MinecraftClient/ChatBots/AutoRelog.cs @@ -129,10 +129,10 @@ namespace MinecraftClient.ChatBots private void LaunchDelayedReconnection(string? msg) { - int delay = random.Next(Settings.DoubleToTick(Config.Delay.min), Settings.DoubleToTick(Config.Delay.max)); - LogDebugToConsoleTranslated(String.IsNullOrEmpty(msg) ? "bot.autoRelog.reconnect_always" : "bot.autoRelog.reconnect", msg); + double delay = random.NextDouble() * (Config.Delay.max - Config.Delay.min) + Config.Delay.min; + LogDebugToConsoleTranslated(string.IsNullOrEmpty(msg) ? "bot.autoRelog.reconnect_always" : "bot.autoRelog.reconnect", msg); LogToConsoleTranslated("bot.autoRelog.wait", delay); - System.Threading.Thread.Sleep(delay * 1000); + System.Threading.Thread.Sleep((int)Math.Floor(delay * 1000)); ReconnectToTheServer(); } diff --git a/MinecraftClient/ChatBots/FollowPlayer.cs b/MinecraftClient/ChatBots/FollowPlayer.cs index 5d202ab1..d5616aab 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 double Update_Limit = 1; + public double Update_Limit = 1.5; [TomlInlineComment("$config.ChatBot.FollowPlayer.Stop_At_Distance$")] public double Stop_At_Distance = 3.0; diff --git a/MinecraftClient/ChatBots/ReplayCapture.cs b/MinecraftClient/ChatBots/ReplayCapture.cs index 4232e8a0..ea34e5cb 100644 --- a/MinecraftClient/ChatBots/ReplayCapture.cs +++ b/MinecraftClient/ChatBots/ReplayCapture.cs @@ -21,7 +21,7 @@ namespace MinecraftClient.ChatBots public bool Enabled = false; [TomlInlineComment("$config.ChatBot.ReplayCapture.Backup_Interval$")] - public int Backup_Interval = 3000; + public double Backup_Interval = 300.0; public void OnSettingUpdate() { @@ -38,7 +38,7 @@ namespace MinecraftClient.ChatBots SetNetworkPacketEventEnabled(true); replay = new ReplayHandler(GetProtocolVersion()); replay.MetaData.serverName = GetServerHost() + GetServerPort(); - backupCounter = Config.Backup_Interval * 10; + backupCounter = Settings.DoubleToTick(Config.Backup_Interval); RegisterChatBotCommand("replay", Translations.Get("bot.replayCapture.cmd"), "replay ", Command); } @@ -55,7 +55,7 @@ namespace MinecraftClient.ChatBots if (backupCounter <= 0) { replay.CreateBackupReplay(@"recording_cache\REPLAY_BACKUP.mcpr"); - backupCounter = Config.Backup_Interval * 10; + backupCounter = Settings.DoubleToTick(Config.Backup_Interval); } else backupCounter--; } diff --git a/MinecraftClient/Resources/lang/de.ini b/MinecraftClient/Resources/lang/de.ini index 32792f5d..9c5e0da5 100644 --- a/MinecraftClient/Resources/lang/de.ini +++ b/MinecraftClient/Resources/lang/de.ini @@ -528,7 +528,7 @@ bot.autoRelog.disconnect_msg=Verbindung wurde mit folgender Nachricht unterbroch bot.autoRelog.reconnect_always=Ignoriere Kick Nachricht und verbinde erneut. bot.autoRelog.reconnect=Nachricht enhält '{0}'. Verbinde erneut. bot.autoRelog.reconnect_ignore=Kick Nachricht enthält keine Schlüsselwörter. Wird ignoriert! -bot.autoRelog.wait=Warte {0} Sekunden vor erneuter Verbindung... +bot.autoRelog.wait=Warte {0:0.000} Sekunden vor erneuter Verbindung... # AutoRespond bot.autoRespond.loading=Loading matches from '{0}' diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 8bb1e67d..97fece71 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -548,7 +548,7 @@ bot.autoRelog.disconnect_msg=Got disconnected with message: {0} bot.autoRelog.reconnect_always=Ignoring kick message, reconnecting anyway. bot.autoRelog.reconnect=Message contains '{0}'. Reconnecting. bot.autoRelog.reconnect_ignore=Message not containing any defined keywords. Ignoring. -bot.autoRelog.wait=Waiting {0} seconds before reconnecting... +bot.autoRelog.wait=Waiting {0:0.000} seconds before reconnecting... # AutoRespond bot.autoRespond.loading=Loading matches from '{0}' diff --git a/MinecraftClient/Resources/lang/fr.ini b/MinecraftClient/Resources/lang/fr.ini index 8f29db97..43197457 100644 --- a/MinecraftClient/Resources/lang/fr.ini +++ b/MinecraftClient/Resources/lang/fr.ini @@ -528,7 +528,7 @@ bot.autoRelog.disconnect_msg=Déconnection détectée avec le message : {0} bot.autoRelog.reconnect_always=Reconnexion quel que soit le contenu du message de kick. bot.autoRelog.reconnect=Le message contient '{0}'. Reconnexion. bot.autoRelog.reconnect_ignore=Le message ne contient aucun des mots clés définis. Pas de reconnexion automatique. -bot.autoRelog.wait=Attente de {0} secondes avant de se reconnecter... +bot.autoRelog.wait=Attente de {0:0.000} secondes avant de se reconnecter... # AutoRespond bot.autoRespond.loading=Chargement des règles depuis '{0}' diff --git a/MinecraftClient/Resources/lang/ru.ini b/MinecraftClient/Resources/lang/ru.ini index 3352c035..cbc0ea5f 100644 --- a/MinecraftClient/Resources/lang/ru.ini +++ b/MinecraftClient/Resources/lang/ru.ini @@ -528,7 +528,7 @@ bot.autoRelog.disconnect_msg=Произошло отключение с сооб bot.autoRelog.reconnect_always=Игнорирует сообщение о пинке, все равно переподключается. bot.autoRelog.reconnect=Сообщение содержит '{0}'. Переподключаемся. bot.autoRelog.reconnect_ignore=Сообщение не содержит определенных ключевых слов. Игнорирование. -bot.autoRelog.wait=Ожидание {0} секунд перед переподключением... +bot.autoRelog.wait=Ожидание {0:0.000} секунд перед переподключением... # AutoRespond bot.autoRespond.loading=Загрузка совпадений из '{0}' diff --git a/MinecraftClient/Resources/lang/vi.ini b/MinecraftClient/Resources/lang/vi.ini index c84b9047..8c1748e4 100644 --- a/MinecraftClient/Resources/lang/vi.ini +++ b/MinecraftClient/Resources/lang/vi.ini @@ -528,7 +528,7 @@ bot.autoRelog.disconnect_msg=Got disconnected with message: {0} bot.autoRelog.reconnect_always=Ignoring kick message, reconnecting anyway. bot.autoRelog.reconnect=Message contains '{0}'. Reconnecting. bot.autoRelog.reconnect_ignore=Message not containing any defined keywords. Ignoring. -bot.autoRelog.wait=Waiting {0} seconds before reconnecting... +bot.autoRelog.wait=Waiting {0:0.000} seconds before reconnecting... # AutoRespond bot.autoRespond.loading=Loading matches from '{0}' diff --git a/MinecraftClient/Resources/lang/zh-Hans.ini b/MinecraftClient/Resources/lang/zh-Hans.ini index 2ecc2f1c..804da7d7 100644 --- a/MinecraftClient/Resources/lang/zh-Hans.ini +++ b/MinecraftClient/Resources/lang/zh-Hans.ini @@ -325,7 +325,7 @@ cmd.inventory.damage=武器伤害值 cmd.inventory.left=左 cmd.inventory.right=右 cmd.inventory.middle=中间 -cmd.inventory.clicking={0}正在点击容器#{2}中的栏位{1} +cmd.inventory.clicking={0}键点击容器#{2}中的栏位{1} cmd.inventory.shiftclick=按住Shift键点击容器#{1}中的栏位{0} cmd.inventory.shiftclick_fail=执行Shift点击失败,这可能是因为该容器类型目前不被支持。 cmd.inventory.no_item=栏位#{0}中没有物品 @@ -548,7 +548,7 @@ bot.autoRelog.disconnect_msg=连接断开,收到消息:{0} bot.autoRelog.reconnect_always=忽略kick消息,仍要重新连接。 bot.autoRelog.reconnect=信息包含 '{0}'。重新连接。 bot.autoRelog.reconnect_ignore=不包含任何已定义关键字的消息,忽略。 -bot.autoRelog.wait=等待{0}秒后重新连接... +bot.autoRelog.wait=等待{0:0.000}秒后重新连接... # AutoRespond bot.autoRespond.loading=正在从'{0}'加载匹配项 diff --git a/MinecraftClient/Resources/lang/zh-Hant.ini b/MinecraftClient/Resources/lang/zh-Hant.ini index 4fcc4163..650711f5 100644 --- a/MinecraftClient/Resources/lang/zh-Hant.ini +++ b/MinecraftClient/Resources/lang/zh-Hant.ini @@ -325,7 +325,7 @@ cmd.inventory.damage=武器傷害值 cmd.inventory.left=左 cmd.inventory.right=右 cmd.inventory.middle=中間 -cmd.inventory.clicking={0}正在點選容器#{2}中的欄位{1} +cmd.inventory.clicking={0}鍵點選容器#{2}中的欄位{1} cmd.inventory.shiftclick=按住Shift鍵點選容器#{1}中的欄位{0} cmd.inventory.shiftclick_fail=執行Shift點選失敗,這可能是因為該容器型別目前不被支援。 cmd.inventory.no_item=欄位#{0}中沒有物品 @@ -548,7 +548,7 @@ bot.autoRelog.disconnect_msg=連線斷開,收到訊息:{0} bot.autoRelog.reconnect_always=忽略kick訊息,仍要重新連線。 bot.autoRelog.reconnect=資訊包含 '{0}'。重新連線。 bot.autoRelog.reconnect_ignore=不包含任何已定義關鍵字的訊息,忽略。 -bot.autoRelog.wait=等待{0}秒後重新連線... +bot.autoRelog.wait=等待{0:0.000}秒後重新連線... # AutoRespond bot.autoRespond.loading=正在從'{0}'載入匹配項