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) ///