mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Fix Auto Relog not applying delay
Also change all debug log to use new method
This commit is contained in:
parent
c97f6f1945
commit
837340dc51
1 changed files with 12 additions and 21 deletions
|
|
@ -26,8 +26,7 @@ namespace MinecraftClient.ChatBots
|
||||||
McClient.ReconnectionAttemptsLeft = attempts;
|
McClient.ReconnectionAttemptsLeft = attempts;
|
||||||
delay = DelayBeforeRelog;
|
delay = DelayBeforeRelog;
|
||||||
if (delay < 1) { delay = 1; }
|
if (delay < 1) { delay = 1; }
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Launching with " + attempts + " reconnection attempts");
|
||||||
LogToConsole("Launching with " + attempts + " reconnection attempts");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
|
|
@ -35,22 +34,19 @@ namespace MinecraftClient.ChatBots
|
||||||
McClient.ReconnectionAttemptsLeft = attempts;
|
McClient.ReconnectionAttemptsLeft = attempts;
|
||||||
if (Settings.AutoRelog_IgnoreKickMessage)
|
if (Settings.AutoRelog_IgnoreKickMessage)
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Initializing without a kick message file");
|
||||||
LogToConsole("Initializing without a kick message file");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (System.IO.File.Exists(Settings.AutoRelog_KickMessagesFile))
|
if (System.IO.File.Exists(Settings.AutoRelog_KickMessagesFile))
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Loading messages from file: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
||||||
LogToConsole("Loading messages from file: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
|
||||||
|
|
||||||
dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile, Encoding.UTF8);
|
dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile, Encoding.UTF8);
|
||||||
|
|
||||||
for (int i = 0; i < dictionary.Length; i++)
|
for (int i = 0; i < dictionary.Length; i++)
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole(" Loaded message: " + dictionary[i]);
|
||||||
LogToConsole(" Loaded message: " + dictionary[i]);
|
|
||||||
dictionary[i] = dictionary[i].ToLower();
|
dictionary[i] = dictionary[i].ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,8 +54,7 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
LogToConsole("File not found: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
LogToConsole("File not found: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
||||||
|
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole(" Current directory was: " + System.IO.Directory.GetCurrentDirectory());
|
||||||
LogToConsole(" Current directory was: " + System.IO.Directory.GetCurrentDirectory());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,21 +63,20 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
if (reason == DisconnectReason.UserLogout)
|
if (reason == DisconnectReason.UserLogout)
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Disconnection initiated by User or MCC bot. Ignoring.");
|
||||||
LogToConsole("Disconnection initiated by User or MCC bot. Ignoring.");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message = GetVerbatim(message);
|
message = GetVerbatim(message);
|
||||||
string comp = message.ToLower();
|
string comp = message.ToLower();
|
||||||
|
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Got disconnected with message: " + message);
|
||||||
LogToConsole("Got disconnected with message: " + message);
|
|
||||||
|
|
||||||
if (Settings.AutoRelog_IgnoreKickMessage)
|
if (Settings.AutoRelog_IgnoreKickMessage)
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Ignoring kick message, reconnecting anyway.");
|
||||||
LogToConsole("Ignoring kick message, reconnecting anyway.");
|
LogToConsole("Waiting " + delay + " seconds before reconnecting...");
|
||||||
|
System.Threading.Thread.Sleep(delay * 1000);
|
||||||
ReconnectToTheServer();
|
ReconnectToTheServer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -91,9 +85,7 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
if (comp.Contains(msg))
|
if (comp.Contains(msg))
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Message contains '" + msg + "'. Reconnecting.");
|
||||||
LogToConsole("Message contains '" + msg + "'. Reconnecting.");
|
|
||||||
|
|
||||||
LogToConsole("Waiting " + delay + " seconds before reconnecting...");
|
LogToConsole("Waiting " + delay + " seconds before reconnecting...");
|
||||||
System.Threading.Thread.Sleep(delay * 1000);
|
System.Threading.Thread.Sleep(delay * 1000);
|
||||||
McClient.ReconnectionAttemptsLeft = attempts;
|
McClient.ReconnectionAttemptsLeft = attempts;
|
||||||
|
|
@ -102,8 +94,7 @@ namespace MinecraftClient.ChatBots
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.DebugMessages)
|
LogDebugToConsole("Message not containing any defined keywords. Ignoring.");
|
||||||
LogToConsole("Message not containing any defined keywords. Ignoring.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue