fix: resolve AutoRelog reconnect errors (#3036)

- Reset _BotRecoAttempts on successful game join so retry counter
  does not carry stale state across sessions
- Display "unlimited" instead of near-int.MaxValue retry count when
  Retries is set to -1 (infinite)
- Guard SendText with CanSendMessage check to prevent
  NullReferenceException when bots call send after disconnect
- Catch SocketException/IOException in Protocol18 Updater thread so
  a closed socket triggers OnConnectionLost gracefully instead of an
  unhandled exception

Made-with: Cursor
This commit is contained in:
BruceChen 2026-04-03 01:26:59 +08:00
parent 2441c67178
commit ca87f1bb5d
5 changed files with 65 additions and 5 deletions

View file

@ -897,6 +897,24 @@ namespace MinecraftClient {
}
}
/// <summary>
/// Looks up a localized string similar to Waiting {0:0.000} seconds before reconnecting... ({1} retries left).
/// </summary>
internal static string bot_autoRelog_wait_with_retries {
get {
return ResourceManager.GetString("bot.autoRelog.wait_with_retries", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to unlimited.
/// </summary>
internal static string bot_autoRelog_retries_unlimited {
get {
return ResourceManager.GetString("bot.autoRelog.retries_unlimited", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File not found: &apos;{0}&apos;.
/// </summary>
@ -6158,6 +6176,15 @@ namespace MinecraftClient {
}
}
/// <summary>
/// Looks up a localized string similar to Cannot send text: not connected to a server..
/// </summary>
internal static string mcc_send_text_not_connected {
get {
return ResourceManager.GetString("mcc.send_text_not_connected", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Waiting {0} seconds before restarting....
/// </summary>

View file

@ -394,6 +394,12 @@
<data name="bot.autoRelog.wait" xml:space="preserve">
<value>Waiting {0:0.000} seconds before reconnecting...</value>
</data>
<data name="bot.autoRelog.wait_with_retries" xml:space="preserve">
<value>Waiting {0:0.000} seconds before reconnecting... ({1} retries left)</value>
</data>
<data name="bot.autoRelog.retries_unlimited" xml:space="preserve">
<value>unlimited</value>
</data>
<data name="bot.autoRespond.file_not_found" xml:space="preserve">
<value>File not found: '{0}'</value>
</data>
@ -2058,6 +2064,9 @@ Type '{0}quit' to leave the server.</value>
<data name="mcc.restart" xml:space="preserve">
<value>Restarting Minecraft Console Client...</value>
</data>
<data name="mcc.send_text_not_connected" xml:space="preserve">
<value>Cannot send text: not connected to a server.</value>
</data>
<data name="mcc.restart_delay" xml:space="preserve">
<value>Waiting {0} seconds before restarting...</value>
</data>