diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index 609ced3b..d6015d5f 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -173,6 +173,43 @@ namespace MinecraftClient.ChatBots inventoryEnabled = GetInventoryEnabled(); if (!inventoryEnabled) LogToConsoleTranslated("bot.autoFish.no_inv_handle"); + + RegisterChatBotCommand("fish", Translations.Get("bot.autoFish.cmd"), GetHelp(), CommandHandler); + } + + public string CommandHandler(string cmd, string[] args) + { + if (args.Length > 0) + { + switch (args[0]) + { + case "start": + isFishing = false; + lock (stateLock) + { + isFishing = false; + counter = 0; + state = FishingState.StartMove; + } + return Translations.Get("bot.autoFish.start"); + case "stop": + isFishing = false; + lock (stateLock) + { + isFishing = false; + if (state == FishingState.WaitingFishToBite) + UseFishRod(); + state = FishingState.Stopping; + } + StopFishing(); + return Translations.Get("bot.autoFish.stop"); + case "help": + return GetCommandHelp(args.Length >= 2 ? args[1] : ""); + default: + return GetHelp(); + } + } + else return GetHelp(); } private void StartFishing() @@ -184,6 +221,7 @@ namespace MinecraftClient.ChatBots LogToConsole(Translations.Get("bot.autoFish.start", delay)); lock (stateLock) { + isFishing = false; counter = Settings.DoubleToTick(delay); state = FishingState.StartMove; } @@ -202,6 +240,7 @@ namespace MinecraftClient.ChatBots isFishing = false; lock (stateLock) { + isFishing = false; state = FishingState.Stopping; } } @@ -512,5 +551,23 @@ namespace MinecraftClient.ChatBots return false; } } + + private static string GetHelp() + { + return Translations.Get("bot.autoFish.available_cmd", "start, stop, help"); + } + + private string GetCommandHelp(string cmd) + { + return cmd.ToLower() switch + { +#pragma warning disable format // @formatter:off + "start" => Translations.Get("bot.autoFish.help.start"), + "stop" => Translations.Get("bot.autoFish.help.stop"), + "help" => Translations.Get("bot.autoFish.help.help"), + _ => GetHelp(), +#pragma warning restore format // @formatter:on + }; + } } } diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 4c8c280e..0eabdae0 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -197,7 +197,7 @@ namespace MinecraftClient if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion)) { needPromptUpdate = false; - ConsoleIO.WriteLineFormatted(Translations.TryGet("mcc.has_update", Settings.GithubLatestReleaseUrl)); + ConsoleIO.WriteLineFormatted(Translations.TryGet("mcc.has_update", Settings.GithubReleaseUrl)); } //Other command-line arguments @@ -328,7 +328,7 @@ namespace MinecraftClient string latestVersion = string.Format("GitHub build {0}, built on {1}-{2}-{3}", run, year, month, day); if (needPromptUpdate) if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion)) - ConsoleIO.WriteLineFormatted(Translations.TryGet("mcc.has_update", Settings.GithubLatestReleaseUrl)); + ConsoleIO.WriteLineFormatted(Translations.TryGet("mcc.has_update", Settings.GithubReleaseUrl)); if (latestVersion != Config.Head.LatestVersion) { Config.Head.LatestVersion = latestVersion; diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 1ed90b50..63a7bb82 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -597,6 +597,13 @@ bot.autoFish.fishing_timeout=Fishing timeout, will soon re-cast. bot.autoFish.cast_timeout=Casting timeout and will soon retry. (Timeout increased to {0:0.0} sec). bot.autoFish.update_lookat=Update yaw = {0:0.00}, pitch = {1:0.00}. bot.autoFish.switch=Switch to the rod in slot {0}, durability {1}/64. +bot.autoFish.cmd=Auto-Fishing ChatBot command +bot.autoFish.available_cmd=Available commands: {0}. Use /fish help for more information. +bot.autoFish.start=Start auto-fishing. +bot.autoFish.stop=Stop auto-fishing. +bot.autoFish.help.start=Start auto-fishing. +bot.autoFish.help.stop=Stop auto-fishing. +bot.autoFish.help.help=Get the command description. Usage: /fish help # AutoRelog bot.autoRelog.launch=Launching with {0} reconnection attempts @@ -900,7 +907,7 @@ config.ChatBot.AutoDrop.Mode="include", "exclude" or "everything". Include: drop config.ChatBot.AutoEat=Automatically eat food when your Hunger value is low\n# You need to enable Inventory Handling to use this bot # ChatBot.AutoFishing -config.ChatBot.AutoFishing=Automatically catch fish using a fishing rod\n# Guide: https://mccteam.github.io/guide/chat-bots.html#auto-fishing\n# /!\ Make sure server rules allow automated farming before using this bot +config.ChatBot.AutoFishing=Automatically catch fish using a fishing rod\n# Guide: https://mccteam.github.io/guide/chat-bots.html#auto-fishing\n# You can use "/fish" to control the bot manually.\n# /!\ Make sure server rules allow automated farming before using this bot config.ChatBot.AutoFishing.Antidespawn=Keep it as false if you have not changed it before. config.ChatBot.AutoFishing.Mainhand=Use the mainhand or the offhand to hold the rod. config.ChatBot.AutoFishing.Auto_Start=Whether to start fishing automatically after entering a world. diff --git a/MinecraftClient/Resources/lang/zh-Hans.ini b/MinecraftClient/Resources/lang/zh-Hans.ini index 201ba051..76f8c972 100644 Binary files a/MinecraftClient/Resources/lang/zh-Hans.ini and b/MinecraftClient/Resources/lang/zh-Hans.ini differ diff --git a/MinecraftClient/Resources/lang/zh-Hant.ini b/MinecraftClient/Resources/lang/zh-Hant.ini index ae5216d1..b015b011 100644 Binary files a/MinecraftClient/Resources/lang/zh-Hant.ini and b/MinecraftClient/Resources/lang/zh-Hant.ini differ