From 47c19466c32a074897ef1afba06b60a4e0bbe234 Mon Sep 17 00:00:00 2001 From: ORelio Date: Sat, 27 Mar 2021 16:43:57 +0100 Subject: [PATCH] Catch exceptions on bot load (#1510) Also return a copy of ChatBot list inside GetLoadedChatBots() because UnloadBot() must be used to properly unload the bot --- MinecraftClient/McClient.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 49d3c143..66525dcb 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -114,12 +114,7 @@ namespace MinecraftClient public int GetProtocolVersion() { return protocolversion; } public ILogger GetLogger() { return this.Log; } public int GetPlayerEntityID() { return playerEntityID; } - - // get bots list for unloading them by commands - public List GetLoadedChatBots() - { - return bots; - } + public List GetLoadedChatBots() { return new List(bots); } TcpClient client; IMinecraftCom handler; @@ -669,9 +664,9 @@ namespace MinecraftClient b.SetHandler(this); bots.Add(b); if (init) - b.Initialize(); + DispatchBotEvent(bot => bot.Initialize(), new ChatBot[] { b }); if (this.handler != null) - b.AfterGameJoined(); + DispatchBotEvent(bot => bot.AfterGameJoined(), new ChatBot[] { b }); Settings.SingleCommand = ""; }