mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Support control by command (/fish)
This commit is contained in:
parent
e9f227ca5b
commit
b949db57cf
5 changed files with 67 additions and 3 deletions
|
|
@ -173,6 +173,43 @@ namespace MinecraftClient.ChatBots
|
||||||
inventoryEnabled = GetInventoryEnabled();
|
inventoryEnabled = GetInventoryEnabled();
|
||||||
if (!inventoryEnabled)
|
if (!inventoryEnabled)
|
||||||
LogToConsoleTranslated("bot.autoFish.no_inv_handle");
|
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()
|
private void StartFishing()
|
||||||
|
|
@ -184,6 +221,7 @@ namespace MinecraftClient.ChatBots
|
||||||
LogToConsole(Translations.Get("bot.autoFish.start", delay));
|
LogToConsole(Translations.Get("bot.autoFish.start", delay));
|
||||||
lock (stateLock)
|
lock (stateLock)
|
||||||
{
|
{
|
||||||
|
isFishing = false;
|
||||||
counter = Settings.DoubleToTick(delay);
|
counter = Settings.DoubleToTick(delay);
|
||||||
state = FishingState.StartMove;
|
state = FishingState.StartMove;
|
||||||
}
|
}
|
||||||
|
|
@ -202,6 +240,7 @@ namespace MinecraftClient.ChatBots
|
||||||
isFishing = false;
|
isFishing = false;
|
||||||
lock (stateLock)
|
lock (stateLock)
|
||||||
{
|
{
|
||||||
|
isFishing = false;
|
||||||
state = FishingState.Stopping;
|
state = FishingState.Stopping;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -512,5 +551,23 @@ namespace MinecraftClient.ChatBots
|
||||||
return false;
|
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
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ namespace MinecraftClient
|
||||||
if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion))
|
if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion))
|
||||||
{
|
{
|
||||||
needPromptUpdate = false;
|
needPromptUpdate = false;
|
||||||
ConsoleIO.WriteLineFormatted(Translations.TryGet("mcc.has_update", Settings.GithubLatestReleaseUrl));
|
ConsoleIO.WriteLineFormatted(Translations.TryGet("mcc.has_update", Settings.GithubReleaseUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Other command-line arguments
|
//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);
|
string latestVersion = string.Format("GitHub build {0}, built on {1}-{2}-{3}", run, year, month, day);
|
||||||
if (needPromptUpdate)
|
if (needPromptUpdate)
|
||||||
if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion))
|
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)
|
if (latestVersion != Config.Head.LatestVersion)
|
||||||
{
|
{
|
||||||
Config.Head.LatestVersion = latestVersion;
|
Config.Head.LatestVersion = latestVersion;
|
||||||
|
|
|
||||||
|
|
@ -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.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.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.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 <cmd name> 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 <command name>
|
||||||
|
|
||||||
# AutoRelog
|
# AutoRelog
|
||||||
bot.autoRelog.launch=Launching with {0} reconnection attempts
|
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
|
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
|
# 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.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.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.
|
config.ChatBot.AutoFishing.Auto_Start=Whether to start fishing automatically after entering a world.
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue