mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
AutoRelog: Allow any kick message
Set ignorekickmessage=true in config See issues #880 #921
This commit is contained in:
parent
dbe02c063c
commit
c5b0f447c9
5 changed files with 41 additions and 15 deletions
|
|
@ -572,6 +572,8 @@ namespace MinecraftClient
|
||||||
/// <param name="delaySeconds">Optional delay, in seconds, before restarting</param>
|
/// <param name="delaySeconds">Optional delay, in seconds, before restarting</param>
|
||||||
protected void ReconnectToTheServer(int ExtraAttempts = 3, int delaySeconds = 0)
|
protected void ReconnectToTheServer(int ExtraAttempts = 3, int delaySeconds = 0)
|
||||||
{
|
{
|
||||||
|
if (Settings.DebugMessages)
|
||||||
|
ConsoleIO.WriteLogLine(String.Format("[{0}] Disconnecting and Reconnecting to the Server", this.GetType().Name));
|
||||||
McTcpClient.ReconnectionAttemptsLeft = ExtraAttempts;
|
McTcpClient.ReconnectionAttemptsLeft = ExtraAttempts;
|
||||||
Program.Restart(delaySeconds);
|
Program.Restart(delaySeconds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,26 +33,34 @@ namespace MinecraftClient.ChatBots
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
McTcpClient.ReconnectionAttemptsLeft = attempts;
|
McTcpClient.ReconnectionAttemptsLeft = attempts;
|
||||||
if (System.IO.File.Exists(Settings.AutoRelog_KickMessagesFile))
|
if (Settings.AutoRelog_IgnoreKickMessage)
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
if (Settings.DebugMessages)
|
||||||
LogToConsole("Loading messages from file: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
LogToConsole("Initializing without a kick message file");
|
||||||
|
|
||||||
dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile);
|
|
||||||
|
|
||||||
for (int i = 0; i < dictionary.Length; i++)
|
|
||||||
{
|
|
||||||
if (Settings.DebugMessages)
|
|
||||||
LogToConsole(" Loaded message: " + dictionary[i]);
|
|
||||||
dictionary[i] = dictionary[i].ToLower();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogToConsole("File not found: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
if (System.IO.File.Exists(Settings.AutoRelog_KickMessagesFile))
|
||||||
|
{
|
||||||
|
if (Settings.DebugMessages)
|
||||||
|
LogToConsole("Loading messages from file: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
||||||
|
|
||||||
if (Settings.DebugMessages)
|
dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile);
|
||||||
LogToConsole(" Current directory was: " + System.IO.Directory.GetCurrentDirectory());
|
|
||||||
|
for (int i = 0; i < dictionary.Length; i++)
|
||||||
|
{
|
||||||
|
if (Settings.DebugMessages)
|
||||||
|
LogToConsole(" Loaded message: " + dictionary[i]);
|
||||||
|
dictionary[i] = dictionary[i].ToLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogToConsole("File not found: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
||||||
|
|
||||||
|
if (Settings.DebugMessages)
|
||||||
|
LogToConsole(" Current directory was: " + System.IO.Directory.GetCurrentDirectory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +69,7 @@ namespace MinecraftClient.ChatBots
|
||||||
if (reason == DisconnectReason.UserLogout)
|
if (reason == DisconnectReason.UserLogout)
|
||||||
{
|
{
|
||||||
if (Settings.DebugMessages)
|
if (Settings.DebugMessages)
|
||||||
LogToConsole("Ignoring disconnection initiated by User or MCC bot");
|
LogToConsole("Disconnection initiated by User or MCC bot. Ignoring.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -71,6 +79,14 @@ namespace MinecraftClient.ChatBots
|
||||||
if (Settings.DebugMessages)
|
if (Settings.DebugMessages)
|
||||||
LogToConsole("Got disconnected with message: " + message);
|
LogToConsole("Got disconnected with message: " + message);
|
||||||
|
|
||||||
|
if (Settings.AutoRelog_IgnoreKickMessage)
|
||||||
|
{
|
||||||
|
if (Settings.DebugMessages)
|
||||||
|
LogToConsole("Ignoring kick message, reconnecting anyway.");
|
||||||
|
ReconnectToTheServer();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (string msg in dictionary)
|
foreach (string msg in dictionary)
|
||||||
{
|
{
|
||||||
if (comp.Contains(msg))
|
if (comp.Contains(msg))
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,10 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
foreach (var item in nbt)
|
foreach (var item in nbt)
|
||||||
{
|
{
|
||||||
|
// Skip NBT root name
|
||||||
|
if (item.Key == "" && root)
|
||||||
|
continue;
|
||||||
|
|
||||||
byte fieldType;
|
byte fieldType;
|
||||||
byte[] fieldNameLength = GetUShort((ushort)item.Key.Length);
|
byte[] fieldNameLength = GetUShort((ushort)item.Key.Length);
|
||||||
byte[] fieldName = Encoding.ASCII.GetBytes(item.Key);
|
byte[] fieldName = Encoding.ASCII.GetBytes(item.Key);
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ namespace MinecraftClient
|
||||||
public static bool AutoRelog_Enabled = false;
|
public static bool AutoRelog_Enabled = false;
|
||||||
public static int AutoRelog_Delay = 10;
|
public static int AutoRelog_Delay = 10;
|
||||||
public static int AutoRelog_Retries = 3;
|
public static int AutoRelog_Retries = 3;
|
||||||
|
public static bool AutoRelog_IgnoreKickMessage = false;
|
||||||
public static string AutoRelog_KickMessagesFile = "kickmessages.txt";
|
public static string AutoRelog_KickMessagesFile = "kickmessages.txt";
|
||||||
|
|
||||||
//Script Scheduler Settings
|
//Script Scheduler Settings
|
||||||
|
|
@ -363,6 +364,7 @@ namespace MinecraftClient
|
||||||
case "enabled": AutoRelog_Enabled = str2bool(argValue); break;
|
case "enabled": AutoRelog_Enabled = str2bool(argValue); break;
|
||||||
case "delay": AutoRelog_Delay = str2int(argValue); break;
|
case "delay": AutoRelog_Delay = str2int(argValue); break;
|
||||||
case "retries": AutoRelog_Retries = str2int(argValue); break;
|
case "retries": AutoRelog_Retries = str2int(argValue); break;
|
||||||
|
case "ignorekickmessage": AutoRelog_IgnoreKickMessage = str2bool(argValue); break;
|
||||||
case "kickmessagesfile": AutoRelog_KickMessagesFile = argValue; break;
|
case "kickmessagesfile": AutoRelog_KickMessagesFile = argValue; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -639,6 +641,7 @@ namespace MinecraftClient
|
||||||
+ "enabled=false\r\n"
|
+ "enabled=false\r\n"
|
||||||
+ "delay=10\r\n"
|
+ "delay=10\r\n"
|
||||||
+ "retries=3 #-1 = unlimited\r\n"
|
+ "retries=3 #-1 = unlimited\r\n"
|
||||||
|
+ "ignorekickmessage=false\r\n"
|
||||||
+ "kickmessagesfile=kickmessages.txt\r\n"
|
+ "kickmessagesfile=kickmessages.txt\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ "[ChatLog]\r\n"
|
+ "[ChatLog]\r\n"
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,7 @@ A kick message "Connection has been lost." is generated by the console itself wh
|
||||||
A kick message "Login failed." is generated the same way when it failed to login to the server.
|
A kick message "Login failed." is generated the same way when it failed to login to the server.
|
||||||
A kick message "Failed to ping this IP." is generated when it failed to ping the server.
|
A kick message "Failed to ping this IP." is generated when it failed to ping the server.
|
||||||
You can use them for reconnecting when connection is lost or the login failed.
|
You can use them for reconnecting when connection is lost or the login failed.
|
||||||
|
If you want to always reconnect, set ignorekickmessage=true in MinecraftClient.ini. Use at own risk!
|
||||||
|
|
||||||
Using the Script Scheduler
|
Using the Script Scheduler
|
||||||
------
|
------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue