diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs
index b5300a48..0dc8b3a6 100644
--- a/MinecraftClient/ChatBot.cs
+++ b/MinecraftClient/ChatBot.cs
@@ -27,7 +27,7 @@ namespace MinecraftClient
///
public abstract class ChatBot
{
- public enum DisconnectReason { InGameKick, LoginRejected, ConnectionLost };
+ public enum DisconnectReason { InGameKick, LoginRejected, ConnectionLost, UserLogout };
//Handler will be automatically set on bot loading, don't worry about this
public void SetHandler(McTcpClient handler) { this._handler = handler; }
diff --git a/MinecraftClient/ChatBots/AutoRelog.cs b/MinecraftClient/ChatBots/AutoRelog.cs
index 2f1dcf1b..b690f13e 100644
--- a/MinecraftClient/ChatBots/AutoRelog.cs
+++ b/MinecraftClient/ChatBots/AutoRelog.cs
@@ -58,29 +58,37 @@ namespace MinecraftClient.ChatBots
public override bool OnDisconnect(DisconnectReason reason, string message)
{
- message = GetVerbatim(message);
- string comp = message.ToLower();
-
- if (Settings.DebugMessages)
- LogToConsole("Got disconnected with message: " + message);
-
- foreach (string msg in dictionary)
+ if (reason == DisconnectReason.UserLogout)
{
- if (comp.Contains(msg))
- {
- if (Settings.DebugMessages)
- LogToConsole("Message contains '" + msg + "'. Reconnecting.");
-
- LogToConsole("Waiting " + delay + " seconds before reconnecting...");
- System.Threading.Thread.Sleep(delay * 1000);
- McTcpClient.ReconnectionAttemptsLeft = attempts;
- ReconnectToTheServer();
- return true;
- }
+ if (Settings.DebugMessages)
+ LogToConsole("Ignoring disconnection initiated by User or MCC bot");
}
+ else
+ {
+ message = GetVerbatim(message);
+ string comp = message.ToLower();
- if (Settings.DebugMessages)
- LogToConsole("Message not containing any defined keywords. Ignoring.");
+ if (Settings.DebugMessages)
+ LogToConsole("Got disconnected with message: " + message);
+
+ foreach (string msg in dictionary)
+ {
+ if (comp.Contains(msg))
+ {
+ if (Settings.DebugMessages)
+ LogToConsole("Message contains '" + msg + "'. Reconnecting.");
+
+ LogToConsole("Waiting " + delay + " seconds before reconnecting...");
+ System.Threading.Thread.Sleep(delay * 1000);
+ McTcpClient.ReconnectionAttemptsLeft = attempts;
+ ReconnectToTheServer();
+ return true;
+ }
+ }
+
+ if (Settings.DebugMessages)
+ LogToConsole("Message not containing any defined keywords. Ignoring.");
+ }
return false;
}
diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs
index 4946d50b..4dc2e8eb 100644
--- a/MinecraftClient/McTcpClient.cs
+++ b/MinecraftClient/McTcpClient.cs
@@ -349,12 +349,12 @@ namespace MinecraftClient
}
///
- /// Disconnect the client from the server
+ /// Disconnect the client from the server (initiated from MCC)
///
public void Disconnect()
{
foreach (ChatBot bot in bots.ToArray())
- bot.OnDisconnect(ChatBot.DisconnectReason.ConnectionLost, "Disconnected");
+ bot.OnDisconnect(ChatBot.DisconnectReason.UserLogout, "");
botsOnHold.Clear();
botsOnHold.AddRange(bots);
@@ -721,7 +721,7 @@ namespace MinecraftClient
}
///
- /// When connection has been lost
+ /// When connection has been lost, login was denied or played was kicked from the server
///
public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
{
@@ -751,6 +751,9 @@ namespace MinecraftClient
ConsoleIO.WriteLine("Login failed :");
ConsoleIO.WriteLineFormatted(message);
break;
+
+ case ChatBot.DisconnectReason.UserLogout:
+ throw new InvalidOperationException("User-initiated logout should be done by calling Disconnect()");
}
foreach (ChatBot bot in bots.ToArray())