mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Added Farmer Bot. Fixed a bug in the configuration. Moved Reload and Bots command to the Commands folder.
This commit is contained in:
parent
77500deef2
commit
6524fe1734
6 changed files with 208 additions and 59 deletions
74
MinecraftClient/Commands/Bots.cs
Normal file
74
MinecraftClient/Commands/Bots.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class Bots : Command
|
||||
{
|
||||
public override string CmdName { get { return "bots"; } }
|
||||
public override string CmdUsage { get { return "bots [list|unload <bot name|all>]"; } }
|
||||
public override string CmdDesc { get { return "cmd.bots.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] args = GetArgs(command);
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (args[0].Equals("list", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
|
||||
int length = handler.GetLoadedChatBots().Count;
|
||||
|
||||
if (length == 0)
|
||||
return Translations.TryGet("cmd.bots.noloaded");
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
sb.Append(handler.GetLoadedChatBots()[i].GetType().Name);
|
||||
|
||||
if (i != length - 1)
|
||||
sb.Append(" ,");
|
||||
|
||||
}
|
||||
|
||||
return Translations.Get("cmd.bots.list") + ": " + sb.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (args[0].Equals("unload", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string botName = args[1].Trim();
|
||||
|
||||
if (botName.ToLower().Equals("all", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (handler.GetLoadedChatBots().Count == 0)
|
||||
return Translations.TryGet("cmd.bots.noloaded");
|
||||
|
||||
handler.UnloadAllBots();
|
||||
return Translations.TryGet("cmd.bots.unloaded_all");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatBot? bot = handler.GetLoadedChatBots().Find(bot => bot.GetType().Name.ToLower() == botName.ToLower());
|
||||
|
||||
if (bot == null)
|
||||
return Translations.TryGet("cmd.bots.notfound", botName);
|
||||
|
||||
handler.BotUnLoad(bot);
|
||||
return Translations.TryGet("cmd.bots.unloaded", botName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
MinecraftClient/Commands/Reload.cs
Normal file
23
MinecraftClient/Commands/Reload.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class Reload : Command
|
||||
{
|
||||
public override string CmdName { get { return "reload"; } }
|
||||
public override string CmdUsage { get { return "reload"; } }
|
||||
public override string CmdDesc { get { return "cmd.reload.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
handler.Log.Info(Translations.TryGet("cmd.reload.started"));
|
||||
handler.ReloadSettings();
|
||||
handler.Log.Warn(Translations.TryGet("cmd.reload.warning1"));
|
||||
handler.Log.Warn(Translations.TryGet("cmd.reload.warning2"));
|
||||
handler.Log.Warn(Translations.TryGet("cmd.reload.warning3"));
|
||||
handler.Log.Warn(Translations.TryGet("cmd.reload.warning4"));
|
||||
|
||||
return Translations.TryGet("cmd.reload.finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue