From 572191dcd2558864405846ed405932f465fb3d79 Mon Sep 17 00:00:00 2001
From: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com>
Date: Fri, 3 Jul 2020 13:19:20 +0800
Subject: [PATCH] Make internal command loads before ChatBot command
---
MinecraftClient/McClient.cs | 58 ++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs
index b8c84e0f..bdff7eab 100644
--- a/MinecraftClient/McClient.cs
+++ b/MinecraftClient/McClient.cs
@@ -158,6 +158,9 @@ namespace MinecraftClient
if (!singlecommand)
{
+ /* Load commands from Commands namespace */
+ LoadCommands();
+
if (botsOnHold.Count == 0)
{
if (Settings.AntiAFK_Enabled) { BotLoad(new ChatBots.AntiAFK(Settings.AntiAFK_Delay)); }
@@ -337,32 +340,6 @@ namespace MinecraftClient
/// TRUE if the command was indeed an internal MCC command
public bool PerformInternalCommand(string command, ref string response_msg, Dictionary localVars = null)
{
- /* Load commands from the 'Commands' namespace */
-
- if (!CommandLoaded)
- {
- Type[] cmds_classes = Program.GetTypesInNamespace("MinecraftClient.Commands");
- foreach (Type type in cmds_classes)
- {
- if (type.IsSubclassOf(typeof(Command)))
- {
- try
- {
- Command cmd = (Command)Activator.CreateInstance(type);
- cmds[cmd.CMDName.ToLower()] = cmd;
- cmd_names.Add(cmd.CMDName.ToLower());
- foreach (string alias in cmd.getCMDAliases())
- cmds[alias.ToLower()] = cmd;
- }
- catch (Exception e)
- {
- ConsoleIO.WriteLogLine(e.Message);
- }
- }
- }
- CommandLoaded = true;
- }
-
/* Process the provided command */
string command_name = command.Split(' ')[0].ToLower();
@@ -411,6 +388,35 @@ namespace MinecraftClient
return true;
}
+ public void LoadCommands()
+ {
+ /* Load commands from the 'Commands' namespace */
+
+ if (!CommandLoaded)
+ {
+ Type[] cmds_classes = Program.GetTypesInNamespace("MinecraftClient.Commands");
+ foreach (Type type in cmds_classes)
+ {
+ if (type.IsSubclassOf(typeof(Command)))
+ {
+ try
+ {
+ Command cmd = (Command)Activator.CreateInstance(type);
+ cmds[cmd.CMDName.ToLower()] = cmd;
+ cmd_names.Add(cmd.CMDName.ToLower());
+ foreach (string alias in cmd.getCMDAliases())
+ cmds[alias.ToLower()] = cmd;
+ }
+ catch (Exception e)
+ {
+ ConsoleIO.WriteLogLine(e.Message);
+ }
+ }
+ }
+ CommandLoaded = true;
+ }
+ }
+
///
/// Disconnect the client from the server (initiated from MCC)
///