diff --git a/MinecraftClient/ChatBots/AutoRelog.cs b/MinecraftClient/ChatBots/AutoRelog.cs
index 316c5ab5..8a42a26c 100644
--- a/MinecraftClient/ChatBots/AutoRelog.cs
+++ b/MinecraftClient/ChatBots/AutoRelog.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using MinecraftClient.Scripting;
using Tomlet.Attributes;
@@ -95,6 +95,11 @@ namespace MinecraftClient.ChatBots
_Initialize();
}
+ public override void AfterGameJoined()
+ {
+ Configs._BotRecoAttempts = 0;
+ }
+
private void _Initialize()
{
McClient.ReconnectionAttemptsLeft = Config.Retries;
@@ -144,10 +149,17 @@ namespace MinecraftClient.ChatBots
{
double delay = random.NextDouble() * (Config.Delay.max - Config.Delay.min) + Config.Delay.min;
LogDebugToConsole(string.Format(string.IsNullOrEmpty(msg) ? Translations.bot_autoRelog_reconnect_always : Translations.bot_autoRelog_reconnect, msg));
-
- // TODO: Change this translation string to add the retries left text
- LogToConsole(string.Format(Translations.bot_autoRelog_wait, delay) + $" ({Config.Retries - Configs._BotRecoAttempts} retries left)");
- ReconnectToTheServer(Config.Retries - Configs._BotRecoAttempts, (int)Math.Floor(delay), true);
+
+ int retriesLeft = Config.Retries - Configs._BotRecoAttempts;
+ if (retriesLeft < 0)
+ retriesLeft = 0;
+
+ string retriesDisplay = Config.Retries == int.MaxValue
+ ? Translations.bot_autoRelog_retries_unlimited
+ : retriesLeft.ToString();
+
+ LogToConsole(string.Format(Translations.bot_autoRelog_wait_with_retries, delay, retriesDisplay));
+ ReconnectToTheServer(retriesLeft, (int)Math.Floor(delay), true);
}
public static bool OnDisconnectStatic(DisconnectReason reason, string message)
diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs
index 394d01cd..ae5e427b 100644
--- a/MinecraftClient/McClient.cs
+++ b/MinecraftClient/McClient.cs
@@ -1579,6 +1579,12 @@ namespace MinecraftClient
if (String.IsNullOrEmpty(text))
return;
+ if (!CanSendMessage)
+ {
+ Log.Warn(Translations.mcc_send_text_not_connected);
+ return;
+ }
+
int maxLength = handler.GetMaxChatMessageLength();
lock (chatQueue)
diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs
index 0085725b..d883e65f 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs
@@ -324,6 +324,12 @@ namespace MinecraftClient.Protocol.Handlers
catch (NullReferenceException)
{
}
+ catch (SocketException)
+ {
+ }
+ catch (System.IO.IOException)
+ {
+ }
if (cancelToken.IsCancellationRequested)
return;
diff --git a/MinecraftClient/Resources/Translations/Translations.Designer.cs b/MinecraftClient/Resources/Translations/Translations.Designer.cs
index 02447274..4647c2f1 100644
--- a/MinecraftClient/Resources/Translations/Translations.Designer.cs
+++ b/MinecraftClient/Resources/Translations/Translations.Designer.cs
@@ -897,6 +897,24 @@ namespace MinecraftClient {
}
}
+ ///
+ /// Looks up a localized string similar to Waiting {0:0.000} seconds before reconnecting... ({1} retries left).
+ ///
+ internal static string bot_autoRelog_wait_with_retries {
+ get {
+ return ResourceManager.GetString("bot.autoRelog.wait_with_retries", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to unlimited.
+ ///
+ internal static string bot_autoRelog_retries_unlimited {
+ get {
+ return ResourceManager.GetString("bot.autoRelog.retries_unlimited", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to File not found: '{0}'.
///
@@ -6158,6 +6176,15 @@ namespace MinecraftClient {
}
}
+ ///
+ /// Looks up a localized string similar to Cannot send text: not connected to a server..
+ ///
+ internal static string mcc_send_text_not_connected {
+ get {
+ return ResourceManager.GetString("mcc.send_text_not_connected", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Waiting {0} seconds before restarting....
///
diff --git a/MinecraftClient/Resources/Translations/Translations.resx b/MinecraftClient/Resources/Translations/Translations.resx
index c9c53ae6..f4b92069 100644
--- a/MinecraftClient/Resources/Translations/Translations.resx
+++ b/MinecraftClient/Resources/Translations/Translations.resx
@@ -394,6 +394,12 @@
Waiting {0:0.000} seconds before reconnecting...
+
+ Waiting {0:0.000} seconds before reconnecting... ({1} retries left)
+
+
+ unlimited
+
File not found: '{0}'
@@ -2058,6 +2064,9 @@ Type '{0}quit' to leave the server.
Restarting Minecraft Console Client...
+
+ Cannot send text: not connected to a server.
+
Waiting {0} seconds before restarting...