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
This commit is contained in:
ORelio 2021-03-27 16:43:57 +01:00
parent c15b071cad
commit 47c19466c3

View file

@ -114,12 +114,7 @@ namespace MinecraftClient
public int GetProtocolVersion() { return protocolversion; } public int GetProtocolVersion() { return protocolversion; }
public ILogger GetLogger() { return this.Log; } public ILogger GetLogger() { return this.Log; }
public int GetPlayerEntityID() { return playerEntityID; } public int GetPlayerEntityID() { return playerEntityID; }
public List<ChatBot> GetLoadedChatBots() { return new List<ChatBot>(bots); }
// get bots list for unloading them by commands
public List<ChatBot> GetLoadedChatBots()
{
return bots;
}
TcpClient client; TcpClient client;
IMinecraftCom handler; IMinecraftCom handler;
@ -669,9 +664,9 @@ namespace MinecraftClient
b.SetHandler(this); b.SetHandler(this);
bots.Add(b); bots.Add(b);
if (init) if (init)
b.Initialize(); DispatchBotEvent(bot => bot.Initialize(), new ChatBot[] { b });
if (this.handler != null) if (this.handler != null)
b.AfterGameJoined(); DispatchBotEvent(bot => bot.AfterGameJoined(), new ChatBot[] { b });
Settings.SingleCommand = ""; Settings.SingleCommand = "";
} }