mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Rewrite Scripting bot respecting the Bot API + Code Optimization
Do NOT put thread sleeps in bots. NEVER. Initialize() and Update() are called in the main thread! Also, a delay should be respected between each chat/command sendind to avoid being kicked. Putting Thread.Sleep() in bots may cause the client to be out of sync with the server or make it lose connection so again do not use them :)
This commit is contained in:
parent
52d603026e
commit
2d174f81c0
5 changed files with 86 additions and 67 deletions
|
|
@ -13,12 +13,7 @@ namespace MinecraftClient
|
|||
|
||||
class Program
|
||||
{
|
||||
// Scripting Bot Parameters - bearbear12345
|
||||
public static bool scripting_enabled;
|
||||
public static string scripting_param;
|
||||
// End Scripting Bot Parameters
|
||||
private static McTcpClient Client;
|
||||
public static McTcpClient B_Client;
|
||||
private static string loginusername = "";
|
||||
private static string user = "";
|
||||
private static string pass = "";
|
||||
|
|
@ -206,22 +201,8 @@ namespace MinecraftClient
|
|||
#endregion
|
||||
handler.BotLoad(new Bots.AutoRelog(delay, retries)); break;
|
||||
|
||||
case "xauth":
|
||||
if (botargs.Length > 2) { handler.BotLoad(new Bots.xAuth(botargs[2])); } break;
|
||||
case "scripting":
|
||||
if (botargs.Length > 2)
|
||||
{
|
||||
scripting_enabled = true;
|
||||
scripting_param = botargs[2];
|
||||
//handler.BotLoad(new Bots.scripting(botargs[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
scripting_enabled = true;
|
||||
scripting_param = "scripting.txt";
|
||||
//Launches later on after connected in MinecraftCom.cs
|
||||
}
|
||||
break;
|
||||
case "xauth": if (botargs.Length > 2) { handler.BotLoad(new Bots.xAuth(botargs[2])); } break;
|
||||
case "scripting": if (botargs.Length > 2) { handler.BotLoad(new Bots.Scripting(botargs[2])); } break;
|
||||
}
|
||||
command = "";
|
||||
}
|
||||
|
|
@ -271,6 +252,15 @@ namespace MinecraftClient
|
|||
new System.Threading.Thread(new System.Threading.ThreadStart(t_restart)).Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnect the current client from the server and exit the app
|
||||
/// </summary>
|
||||
|
||||
public static void Exit()
|
||||
{
|
||||
new System.Threading.Thread(new System.Threading.ThreadStart(t_exit)).Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pause the program, usually when an error or a kick occured, letting the user press Enter to quit OR type /reconnect
|
||||
/// </summary>
|
||||
|
|
@ -297,5 +287,15 @@ namespace MinecraftClient
|
|||
Console.WriteLine("Restarting Minecraft Console Client...");
|
||||
InitializeClient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Private thread for exiting the program. Called through Exit()
|
||||
/// </summary>
|
||||
|
||||
private static void t_exit()
|
||||
{
|
||||
if (Client != null) { Client.Disconnect(); ConsoleIO.Reset(); }
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue