diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index c84ff57d..fd58719a 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -75,10 +75,22 @@ namespace MinecraftClient /// /// Anything you want to initialize your bot, will be called on load by MinecraftCom + /// + /// NOTE: Chat messages cannot be sent at this point in the login process. If you want to send + /// a message when the bot is loaded, use AfterGameJoined. /// public virtual void Initialize() { } + /// + /// Called after the server has been joined successfully and chat messages are able to be sent. + /// + /// NOTE: This is not always right after joining the server - if the bot was loaded after logging + /// in this is still called. + /// + + public virtual void AfterGameJoined() { } + /// /// Will be called every ~100ms (10fps) if loaded in MinecraftCom /// diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 7e9c95b7..35eaa124 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -27,7 +27,16 @@ namespace MinecraftClient private readonly List bots = new List(); private static readonly List scripts_on_hold = new List(); - public void BotLoad(ChatBot b) { b.SetHandler(this); bots.Add(b); b.Initialize(); Settings.SingleCommand = ""; } + public void BotLoad(ChatBot b) { + b.SetHandler(this); + bots.Add(b); + b.Initialize(); + if (this.handler != null) + { + b.AfterGameJoined(); + } + Settings.SingleCommand = ""; + } public void BotUnLoad(ChatBot b) { bots.RemoveAll(item => object.ReferenceEquals(item, b)); @@ -351,6 +360,8 @@ namespace MinecraftClient { if (!String.IsNullOrWhiteSpace(Settings.BrandInfo)) handler.SendBrandInfo(Settings.BrandInfo.Trim()); + foreach (ChatBot bot in bots) + bot.AfterGameJoined(); } ///