mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Optimize ChatBot loading.
This commit is contained in:
parent
096ea0c70c
commit
87026e1bfb
13 changed files with 264 additions and 249 deletions
|
|
@ -53,7 +53,7 @@ namespace MinecraftClient.Commands
|
|||
private int DoListBot(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
int length = handler.GetLoadedChatBots().Count;
|
||||
int length = handler.GetLoadedChatBots().Length;
|
||||
if (length == 0)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_bots_noloaded);
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ namespace MinecraftClient.Commands
|
|||
McClient handler = CmdResult.currentHandler!;
|
||||
if (botName.ToLower().Equals("all", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (handler.GetLoadedChatBots().Count == 0)
|
||||
if (handler.GetLoadedChatBots().Length == 0)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_bots_noloaded);
|
||||
else
|
||||
{
|
||||
|
|
@ -83,12 +83,20 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
ChatBot? bot = handler.GetLoadedChatBots().Find(bot => bot.GetType().Name.ToLower() == botName.ToLower());
|
||||
if (bot == null)
|
||||
ChatBot? target = null;
|
||||
foreach (ChatBot bot in handler.GetLoadedChatBots())
|
||||
{
|
||||
if (bot.GetType().Name.Equals(botName, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
target = bot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (target == null)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_bots_notfound, botName));
|
||||
else
|
||||
{
|
||||
handler.BotUnLoad(bot).Wait();
|
||||
handler.BotUnLoad(target).Wait();
|
||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_bots_unloaded, botName));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue