mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add an "AfterGameJoined" method to ChatBot.cs.
Since messages can't be sent in Initialize(), a method that's called when the chat bot can first send messages is needed. This method is called when the login completes or when the bot is loaded if the login is already been completed.
This commit is contained in:
parent
1ea8f119d9
commit
6d4ec86619
2 changed files with 24 additions and 1 deletions
|
|
@ -75,10 +75,22 @@ namespace MinecraftClient
|
|||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
|
||||
public virtual void Initialize() { }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
|
||||
public virtual void AfterGameJoined() { }
|
||||
|
||||
/// <summary>
|
||||
/// Will be called every ~100ms (10fps) if loaded in MinecraftCom
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,16 @@ namespace MinecraftClient
|
|||
|
||||
private readonly List<ChatBot> bots = new List<ChatBot>();
|
||||
private static readonly List<ChatBots.Script> scripts_on_hold = new List<ChatBots.Script>();
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue