mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Added command for reloading settings, chat bots, listing chat bots and unloading a chat bot manually by name.
This commit is contained in:
parent
ef79ca1fe8
commit
9b407dbdad
7 changed files with 198 additions and 46 deletions
|
|
@ -54,29 +54,6 @@ namespace MinecraftClient.ChatBots
|
|||
LogToConsoleTranslated("bot.autoFish.no_inv_handle");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update settings when reloaded
|
||||
/// </summary>
|
||||
public /* override */ void OnSettingsReload()
|
||||
{
|
||||
if (Settings.AutoFishing_Enabled)
|
||||
{
|
||||
if (!GetEntityHandlingEnabled())
|
||||
{
|
||||
LogToConsoleTranslated("extra.entity_required");
|
||||
state = FishingState.WaitJoinGame;
|
||||
}
|
||||
inventoryEnabled = GetInventoryEnabled();
|
||||
if (!inventoryEnabled)
|
||||
LogToConsoleTranslated("bot.autoFish.no_inv_handle");
|
||||
}
|
||||
else
|
||||
{
|
||||
UnloadBot();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void StartFishing()
|
||||
{
|
||||
isFishing = false;
|
||||
|
|
@ -262,7 +239,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (Settings.AutoFishing_LogFishingBobber)
|
||||
LogToConsole(string.Format("FishingBobber {0} Dx={1:0.000000} Dy={2:0.000000} Dz={3:0.000000}", Pos, Dx, Math.Abs(Dy), Dz));
|
||||
|
||||
if (Math.Abs(Dx) < Math.Abs(Settings.AutoFishing_StationaryThreshold) &&
|
||||
if (Math.Abs(Dx) < Math.Abs(Settings.AutoFishing_StationaryThreshold) &&
|
||||
Math.Abs(Dz) < Math.Abs(Settings.AutoFishing_StationaryThreshold) &&
|
||||
Math.Abs(Dy) > Math.Abs(Settings.AutoFishing_HookThreshold))
|
||||
{
|
||||
|
|
|
|||
76
MinecraftClient/ChatBots/BotsCommand.cs
Normal file
76
MinecraftClient/ChatBots/BotsCommand.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using MinecraftClient.Mapping;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class BotsCommand : 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
MinecraftClient/ChatBots/Reload.cs
Normal file
27
MinecraftClient/ChatBots/Reload.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using MinecraftClient.Mapping;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
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