From d4f8dd0bfb96927d20dcb72b85b588ae313999e1 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Fri, 21 Oct 2022 19:05:49 +0800 Subject: [PATCH] Upgrade AutoFishing & Bug fix --- MinecraftClient/ChatBots/AutoFishing.cs | 82 ++++++++++--- MinecraftClient/ChatBots/DiscordBridge.cs | 14 ++- MinecraftClient/Inventory/Item.cs | 13 +- MinecraftClient/Program.cs | 2 +- MinecraftClient/Resources/lang/de.ini | Bin 70464 -> 73092 bytes MinecraftClient/Resources/lang/en.ini | 112 ++++++++++++------ MinecraftClient/Resources/lang/fr.ini | Bin 72428 -> 75050 bytes MinecraftClient/Resources/lang/ru.ini | Bin 69552 -> 72174 bytes MinecraftClient/Resources/lang/vi.ini | Bin 65850 -> 68472 bytes MinecraftClient/Resources/lang/zh-Hans.ini | Bin 73534 -> 76364 bytes MinecraftClient/Resources/lang/zh-Hant.ini | Bin 73614 -> 76446 bytes MinecraftClient/Scripting/AssemblyResolver.cs | 2 +- MinecraftClient/Scripting/ChatBot.cs | 27 +++-- MinecraftClient/Settings.cs | 8 +- README.md | 12 +- 15 files changed, 183 insertions(+), 89 deletions(-) diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index 3849f161..8e53992a 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Text; using MinecraftClient.Inventory; using MinecraftClient.Mapping; using Tomlet.Attributes; @@ -143,7 +145,8 @@ namespace MinecraftClient.ChatBots private Entity? fishingBobber; private Location LastPos = Location.Zero; private DateTime CaughtTime = DateTime.Now; - private int fishItemCounter = 10; + private int fishItemCounter = 15; + private Dictionary fishItemCnt = new(); private Entity fishItem = new(-1, EntityType.Item, Location.Zero); private int counter = 0; @@ -182,7 +185,7 @@ namespace MinecraftClient.ChatBots public string CommandHandler(string cmd, string[] args) { - if (args.Length > 0) + if (args.Length >= 1) { switch (args[0]) { @@ -206,13 +209,47 @@ namespace MinecraftClient.ChatBots } StopFishing(); return Translations.Get("bot.autoFish.stop"); + case "status": + if (args.Length >= 2) + { + if (args[1] == "clear") + { + fishItemCnt = new(); + return Translations.Get("bot.autoFish.status_clear"); + } + else + { + return GetCommandHelp("status"); + } + } + else + { + if (fishItemCnt.Count == 0) + return Translations.Get("bot.autoFish.status_info"); + + List> orderedList = fishItemCnt.OrderBy(x => x.Value).ToList(); + int maxLen = orderedList[^1].Value.ToString().Length; + StringBuilder sb = new(); + sb.Append(Translations.Get("bot.autoFish.status_info")); + foreach ((ItemType type, uint cnt) in orderedList) + { + sb.Append(Environment.NewLine); + + string cntStr = cnt.ToString(); + sb.Append(' ', maxLen - cntStr.Length).Append(cntStr); + sb.Append(" x "); + sb.Append(Item.GetTypeString(type)); + } + return sb.ToString(); + } case "help": return GetCommandHelp(args.Length >= 2 ? args[1] : ""); default: return GetHelp(); } } - else return GetHelp(); + else + return GetHelp(); } private void StartFishing() @@ -246,7 +283,7 @@ namespace MinecraftClient.ChatBots isFishing = false; state = FishingState.Stopping; } - fishItemCounter = 10; + fishItemCounter = 15; } private void UseFishRod() @@ -259,8 +296,9 @@ namespace MinecraftClient.ChatBots public override void Update() { - if (fishItemCounter < 10) + if (fishItemCounter < 15) ++fishItemCounter; + lock (stateLock) { switch (state) @@ -283,7 +321,7 @@ namespace MinecraftClient.ChatBots { if (castTimeout < 6000) castTimeout *= 2; // Exponential backoff - LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.cast_timeout", castTimeout / 10.0)); + LogToConsole(GetShortTimestamp() + ": " + Translations.Get("bot.autoFish.cast_timeout", castTimeout / 10.0)); counter = Settings.DoubleToTick(Config.Cast_Delay); state = FishingState.WaitingToCast; @@ -292,7 +330,7 @@ namespace MinecraftClient.ChatBots case FishingState.WaitingFishToBite: if (++counter > Settings.DoubleToTick(Config.Fishing_Timeout)) { - LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.fishing_timeout")); + LogToConsole(GetShortTimestamp() + ": " + Translations.Get("bot.autoFish.fishing_timeout")); counter = Settings.DoubleToTick(Config.Cast_Delay); state = FishingState.WaitingToCast; @@ -347,8 +385,8 @@ namespace MinecraftClient.ChatBots public override void OnEntitySpawn(Entity entity) { - if (fishItemCounter < 10 && entity.Type == EntityType.Item && Math.Abs(entity.Location.Y - LastPos.Y) < 2.0 && - Math.Abs(entity.Location.X - LastPos.X) < 0.1 && Math.Abs(entity.Location.Z - LastPos.Z) < 0.1) + if (fishItemCounter < 15 && entity.Type == EntityType.Item && Math.Abs(entity.Location.Y - LastPos.Y) < 2.2 && + Math.Abs(entity.Location.X - LastPos.X) < 0.12 && Math.Abs(entity.Location.Z - LastPos.Z) < 0.12) { if (Config.Log_Fish_Bobber) LogToConsole(string.Format("Item ({0}) spawn at {1}, distance = {2:0.00}", entity.ID, entity.Location, entity.Location.Distance(LastPos))); @@ -359,9 +397,9 @@ namespace MinecraftClient.ChatBots if (Config.Log_Fish_Bobber) LogToConsole(string.Format("FishingBobber spawn at {0}, distance = {1:0.00}", entity.Location, GetCurrentLocation().Distance(entity.Location))); - fishItemCounter = 10; + fishItemCounter = 15; - LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.throw")); + LogToConsole(GetShortTimestamp() + ": " + Translations.Get("bot.autoFish.throw")); lock (stateLock) { fishingBobber = entity; @@ -377,7 +415,7 @@ namespace MinecraftClient.ChatBots public override void OnEntityDespawn(Entity entity) { - if (entity != null && entity.Type == EntityType.FishingBobber && entity.ID == fishingBobber!.ID) + if (entity != null && fishingBobber != null && entity.Type == EntityType.FishingBobber && entity.ID == fishingBobber!.ID) { if (Config.Log_Fish_Bobber) LogToConsole(string.Format("FishingBobber despawn at {0}", entity.Location)); @@ -431,10 +469,15 @@ namespace MinecraftClient.ChatBots public override void OnEntityMetadata(Entity entity, Dictionary metadata) { - if (fishItemCounter < 10 && entity.ID == fishItem.ID && metadata.TryGetValue(8, out object? item)) + if (fishItemCounter < 15 && entity.ID == fishItem.ID && metadata.TryGetValue(8, out object? itemObj)) { - LogToConsole(Translations.Get("bot.autoFish.got", ((Item)item!).ToFullString())); - fishItemCounter = 10; + fishItemCounter = 15; + Item item = (Item)itemObj!; + LogToConsole(Translations.Get("bot.autoFish.got", item.ToFullString())); + if (fishItemCnt.ContainsKey(item.Type)) + fishItemCnt[item.Type] += (uint)item.Count; + else + fishItemCnt.Add(item.Type, (uint)item.Count); } } @@ -471,10 +514,10 @@ namespace MinecraftClient.ChatBots { ++fishCount; if (Config.Enable_Move && Config.Movements.Length > 0) - LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.caught_at", + LogToConsole(GetShortTimestamp() + ": " + Translations.Get("bot.autoFish.caught_at", fishingBobber!.Location.X, fishingBobber!.Location.Y, fishingBobber!.Location.Z, fishCount)); else - LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.caught", fishCount)); + LogToConsole(GetShortTimestamp() + ": " + Translations.Get("bot.autoFish.caught", fishCount)); lock (stateLock) { @@ -580,7 +623,7 @@ namespace MinecraftClient.ChatBots private static string GetHelp() { - return Translations.Get("bot.autoFish.available_cmd", "start, stop, help"); + return Translations.Get("bot.autoFish.available_cmd", "start, stop, status, help"); } private string GetCommandHelp(string cmd) @@ -590,8 +633,9 @@ namespace MinecraftClient.ChatBots #pragma warning disable format // @formatter:off "start" => Translations.Get("bot.autoFish.help.start"), "stop" => Translations.Get("bot.autoFish.help.stop"), + "status" => Translations.Get("bot.autoFish.help.status"), "help" => Translations.Get("bot.autoFish.help.help"), - _ => GetHelp(), + _ => GetHelp(), #pragma warning restore format // @formatter:on }; } diff --git a/MinecraftClient/ChatBots/DiscordBridge.cs b/MinecraftClient/ChatBots/DiscordBridge.cs index ca6d425a..ef97820b 100644 --- a/MinecraftClient/ChatBots/DiscordBridge.cs +++ b/MinecraftClient/ChatBots/DiscordBridge.cs @@ -1,11 +1,11 @@ -using DSharpPlus; -using System.Threading.Tasks; -using System; -using Tomlet.Attributes; +using System; using System.Linq; +using System.Threading.Tasks; +using DSharpPlus; using DSharpPlus.Entities; using DSharpPlus.Exceptions; using Microsoft.Extensions.Logging; +using Tomlet.Attributes; namespace MinecraftClient.ChatBots { @@ -34,12 +34,14 @@ namespace MinecraftClient.ChatBots public ulong ChannelId = 1018565295654326364L; [TomlInlineComment("$config.ChatBot.DiscordBridge.OwnersIds$")] - public ulong[]? OwnersIds = new[] { 978757810781323276UL }; + public ulong[] OwnersIds = new[] { 978757810781323276UL }; [TomlPrecedingComment("$config.ChatBot.DiscordBridge.Formats$")] public string PrivateMessageFormat = "**[Private Message]** {username}: {message}"; public string PublicMessageFormat = "{username}: {message}"; public string TeleportRequestMessageFormat = "A new Teleport Request from **{username}**!"; + + public void OnSettingUpdate() { } } public override void Initialize() @@ -178,7 +180,7 @@ namespace MinecraftClient.ChatBots if (e.Channel.Id != Config.ChannelId) return; - if (!Config.OwnersIds!.Contains(e.Author.Id)) + if (!Config.OwnersIds.Contains(e.Author.Id)) return; string message = e.Message.Content.Trim(); diff --git a/MinecraftClient/Inventory/Item.cs b/MinecraftClient/Inventory/Item.cs index fff591e5..5b4b7941 100644 --- a/MinecraftClient/Inventory/Item.cs +++ b/MinecraftClient/Inventory/Item.cs @@ -113,17 +113,22 @@ namespace MinecraftClient.Inventory } } - public string GetTypeString() + public static string GetTypeString(ItemType type) { - string type = Type.ToString(); - string type_renamed = type.ToUnderscoreCase(); + string type_str = type.ToString(); + string type_renamed = type_str.ToUnderscoreCase(); string? res1 = Protocol.ChatParser.TranslateString("item.minecraft." + type_renamed); if (!string.IsNullOrEmpty(res1)) return res1; string? res2 = Protocol.ChatParser.TranslateString("block.minecraft." + type_renamed); if (!string.IsNullOrEmpty(res2)) return res2; - return type; + return type_str; + } + + public string GetTypeString() + { + return GetTypeString(Type); } public string ToFullString() diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 0eabdae0..5f7c5bf0 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -691,7 +691,7 @@ namespace MinecraftClient public static void ReloadSettings() { if(Settings.LoadFromFile(settingsIniPath).Item1) - ConsoleIO.WriteLine(Translations.TryGet("config.loading", settingsIniPath)); + ConsoleIO.WriteLine(Translations.TryGet("config.load", settingsIniPath)); } /// diff --git a/MinecraftClient/Resources/lang/de.ini b/MinecraftClient/Resources/lang/de.ini index cc7b0f4eb6d1319868fb050fda57579299a99941..b8eb67895321902a570b848d2cb469205fd4bea2 100644 GIT binary patch delta 1658 zcma)7Ur1A76#qV*Q|C4|b-ON^e>TO`A?~S{M6_jSS%f}BFKTY-a&D#*?L{+s@Fh}C zc`YcgB2uB$s}^K2DtUojcE6$;HQ# zfo2mdXUcVMVk7lS<$_o^VF`>XHls+nrQJ*&Me3 zLk5<5wa_st7cxfMrICI*p>vG$nx4c7Gh@x6I=_h=KmaW55d>64av;xhsnsF^tHhIf zlt4Z{?f9<3dHur;PI6~&Z_8dTgZX740WPGV7LlOnLP#03Ik@Cq13^*BrEWk9QUZGJ z#N;r}Yp@CD`Yd+MkIhvf-*%jX74ptS8Jzp*f z*oIPUssUs3aUd+ixdlB~7H)xbQ9HC)Wa4%hC2v;JRL!@}5fTdTNKS)|mf zOi+K~m~UDz-$On{l0q2&Df$Ohn0LXQs4mpxf5sdW)yV!U8b~2(fBaWkYA{R%h@WY+ Pf_Fty zlW?>Olg_vflOU}clW?>Olg_vblMcBull+?slW@8Yvw*pV29x}o3X>4Q7_(HscmtF0 z!-A7U&K9$L&N>Z~THFe=+}oT1lQ7;SvxMI80h4OR7Lz*15R>HF7Lz>34zt$A!~&BF z$|jTc%NDbA%7O!vs*Mn{rr`VmlU(E?v-sj*1e1K{w38C;60<(&QY^QQ76JAK;Zc0w diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 53318238..0971529e 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -477,20 +477,24 @@ cmd.useitem.use=Used an item # ChatBots. Naming style: bot.. # Alerts +botname.Alerts=Alerts bot.alerts.start_rain=§cWeather change: It is raining now.§r bot.alerts.end_rain=§cWeather change: It is no longer raining.§r bot.alerts.start_thunderstorm=§cWeather change: It is a thunderstorm.§r bot.alerts.end_thunderstorm=§cWeather change: It is no longer a thunderstorm.§r # Anti AFK +botname.AntiAFK=AntiAFK bot.antiafk.not_using_terrain_handling=The terrain handling is not enabled in the settings of the client, enable it if you want to use it with this bot. Using alternative (command) method. bot.antiafk.swapping=The time range begins with a bigger value, swapped them around. bot.antiafk.invalid_walk_range=Invalid walk range provided, must be a positive integer greater than 0, using default value of 5! # AutoAttack +botname.AutoAttack=AutoAttack bot.autoAttack.invalidcooldown=Attack cooldown value cannot be smaller than 0. # AutoCraft +botname.AutoCraft=AutoCraft bot.autoCraft.cmd=Auto-crafting ChatBot command bot.autoCraft.alias=Auto-crafting ChatBot command alias bot.autoCraft.cmd.list=Total {0} recipes loaded: {1} @@ -523,6 +527,7 @@ bot.autocraft.invaild_slots=The number of slots does not match and has been adju bot.autocraft.invaild_invaild_result=Invalid result item! # AutoDig +botname.AutoDig=AutoDig bot.autodig.start_delay=Digging will start in {0:0.0} second(s). bot.autodig.dig_timeout=Digging block timeout, retry. bot.autodig.not_allow=The block currently pointed to is not in the allowed list. @@ -535,6 +540,7 @@ bot.autodig.help.stop=Deactivate the automatic digging bot. bot.autodig.help.help=Get the command description. Usage: /digbot help # AutoDrop +botname.AutoDrop=AutoDrop bot.autoDrop.cmd=AutoDrop ChatBot command bot.autoDrop.alias=AutoDrop ChatBot command alias bot.autoDrop.on=AutoDrop enabled @@ -550,7 +556,11 @@ bot.autoDrop.unknown_mode=Unknwon mode. Available modes: Include, Exclude, Every bot.autoDrop.no_mode=Cannot read drop mode from config. Using include mode. bot.autoDrop.no_inventory=Cannot find inventory {0}! +# AutoEat +botname.AutoEat=AutoEat + # AutoFish +botname.AutoFishing=AutoFishing bot.autoFish.no_inv_handle=Inventory handling is not enabled. Cannot check rod durability and switch rods. bot.autoFish.start_at=Fishing will start in {0:0.0} second(s). bot.autoFish.throw=Casting successfully. @@ -563,15 +573,20 @@ 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.status_info=All items obtained from fishing (not entirely accurate): +# AutoFish cmd 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.status_clear=The record of the obtained items has been cleared. bot.autoFish.help.start=Start auto-fishing. bot.autoFish.help.stop=Stop auto-fishing. +bot.autoFish.help.status=List all obtained items. Or use "/fish status clear" to clear the list. bot.autoFish.help.help=Get the command description. Usage: /fish help # AutoRelog +botname.AutoRelog=AutoRelog bot.autoRelog.launch=Launching with {0} reconnection attempts bot.autoRelog.no_kick_msg=Initializing without a kick message file bot.autoRelog.loading=Loading messages from file: {0} @@ -586,6 +601,7 @@ bot.autoRelog.reconnect_ignore=Message not containing any defined keywords. Igno bot.autoRelog.wait=Waiting {0:0.000} seconds before reconnecting... # AutoRespond +botname.AutoRespond=AutoRespond bot.autoRespond.loading=Loading matches from '{0}' bot.autoRespond.file_not_found=File not found: '{0}' bot.autoRespond.loaded_match=Loaded match:\n{0} @@ -595,9 +611,11 @@ bot.autoRespond.match_run=Running action: {0} bot.autoRespond.match=match: {0}\nregex: {1}\naction: {2}\nactionPrivate: {3}\nactionOther: {4}\nownersOnly: {5}\ncooldown: {6} # ChatLog +botname.ChatLog=ChatLog bot.chatLog.invalid_file=Path '{0}' contains invalid characters. # DiscordBridge +botname.DiscordBridge=DiscordBridge bot.DiscordBridge.command_executed=The command was executed with the result bot.DiscordBridge.connected=Succesfully connected with MCC! bot.DiscordBridge.missing_token=Please provide a valid token! @@ -605,7 +623,51 @@ bot.DiscordBridge.guild_not_found=The provided guild/server with an id '{0}' has bot.DiscordBridge.channel_not_found=The provided channel with an id '{0}' has not been found! bot.DiscordBridge.unknown_error=An unknown error has occured! +# Farmer +botname.Farmer=Farmer +bot.farmer.desc=Farming bot +bot.farmer.not_implemented=Not implemented bellow 1.13! +bot.farmer.already_stopped=The bot has already stopped farming! +bot.farmer.stopping=Stoping farming, this might take a second... +bot.farmer.stopped=Stopped farming! +bot.farmer.already_running=The bot is already farming! +bot.farmer.invalid_crop_type=Invalid crop type provided (Types which you can use: Beetroot, Carrot, Melon, Netherwart, Pumpkin, Potato, Wheat)! +bot.farmer.warining_invalid_parameter=Invalid parameter "{0}" provided (Use format: "key:value")! +bot.farmer.invalid_radius=Invalid radius provided, you must provide a valid integer number greater than 0! +bot.farmer.warining_force_unsafe=You have enabled un-safe movement, the bot might get hurt! +bot.farmer.warining_allow_teleport=You have enabled teleporting, this might get your bot account kicked and in the worst case scenario banned! Use with caution! +bot.farmer.started=Started farming! +bot.farmer.crop_type=Crop type +bot.farmer.radius=Radius +bot.farmer.needs_terrain=The Farmer bot needs Terrain Handling in order to work, please enable it! +bot.farmer.needs_inventory=The Farmer bot needs Inventory Handling in order to work, please enable it! + +# Follow player +botname.FollowPlayer=FollowPlayer +cmd.follow.desc=Makes the bot follow a specified player +cmd.follow.usage=follow [-f] (Use -f to enable un-safe walking) +cmd.follow.already_stopped=Already stopped +cmd.follow.stopping=Stopped following! +cmd.follow.invalid_name=Invalid or empty player name provided! +cmd.follow.invalid_player=The specified player is either not connected out out of the range! +cmd.follow.cant_reach_player=Can not reach the player, he is either in chunks that are not loaded, too far away or not reachable by a bot due to obstacles like gaps or water bodies! +cmd.follow.already_following=Already following {0}! +cmd.follow.switched=Switched to following {0}! +cmd.follow.started=Started following {0}! +cmd.follow.unsafe_enabled=Enabled us-safe walking (NOTE: The bot might die or get hurt!) +cmd.follow.note=NOTE: The bot is quite slow, you need to walk slowly and at a close distance for it to be able to keep up, kinda like when you make animals follow you by holding food in your hand. This is a limitation due to a pathfinding algorithm, we are working to get a better one. +cmd.follow.player_came_to_the_range=The player {0} came back to the range! +cmd.follow.resuming=Resuming to follow! +cmd.follow.player_left_the_range=The player {0} has left the range! +cmd.follow.pausing=Pausing! +cmd.follow.player_left=The player {0} left the server! +cmd.follow.stopping=Stopped! + +# HangmanGame +botname.HangmanGame=HangmanGame + # Mailer +botname.Mailer=Mailer bot.mailer.init=Initializing Mailer with settings: bot.mailer.init.db= - Database File: {0} bot.mailer.init.ignore= - Ignore List: {0} @@ -638,6 +700,7 @@ bot.mailer.cmd.ignore.invalid=Missing or invalid name. Usage: {0} bot.mailer.cmd.help=See usage # Maps +botname.Map=Map bot.map.cmd.desc=Render maps (item maps) bot.map.cmd.not_found=A map with id '{0}' does not exists! bot.map.cmd.invalid_id=Invalid ID provided, must be a number! @@ -649,57 +712,28 @@ bot.map.failed_to_render=Failed to render the map with id: '{0}' bot.map.list_item=- Map id: {0} (Last Updated: {1}) bot.map.scale=The size of the map is reduced from ({0}x{1}) to ({2}x{3}) due to the size limitation of the current terminal. +# PlayerListLogger +botname.PlayerListLogger=PlayerListLogger + +# RemoteControl +botname.RemoteControl=RemoteControl + # ReplayCapture +botname.ReplayCapture=ReplayCapture bot.replayCapture.cmd=replay command bot.replayCapture.created=Replay file created. bot.replayCapture.stopped=Record stopped. bot.replayCapture.restart=Record was stopped. Restart the program to start another record. -# Farmer -bot.farmer.desc=Farming bot -bot.farmer.not_implemented=Not implemented bellow 1.13! -bot.farmer.already_stopped=The bot has already stopped farming! -bot.farmer.stopping=Stoping farming, this might take a second... -bot.farmer.stopped=Stopped farming! -bot.farmer.already_running=The bot is already farming! -bot.farmer.invalid_crop_type=Invalid crop type provided (Types which you can use: Beetroot, Carrot, Melon, Netherwart, Pumpkin, Potato, Wheat)! -bot.farmer.warining_invalid_parameter=Invalid parameter "{0}" provided (Use format: "key:value")! -bot.farmer.invalid_radius=Invalid radius provided, you must provide a valid integer number greater than 0! -bot.farmer.warining_force_unsafe=You have enabled un-safe movement, the bot might get hurt! -bot.farmer.warining_allow_teleport=You have enabled teleporting, this might get your bot account kicked and in the worst case scenario banned! Use with caution! -bot.farmer.started=Started farming! -bot.farmer.crop_type=Crop type -bot.farmer.radius=Radius -bot.farmer.needs_terrain=The Farmer bot needs Terrain Handling in order to work, please enable it! -bot.farmer.needs_inventory=The Farmer bot needs Inventory Handling in order to work, please enable it! - -# Follow player -cmd.follow.desc=Makes the bot follow a specified player -cmd.follow.usage=follow [-f] (Use -f to enable un-safe walking) -cmd.follow.already_stopped=Already stopped -cmd.follow.stopping=Stopped following! -cmd.follow.invalid_name=Invalid or empty player name provided! -cmd.follow.invalid_player=The specified player is either not connected out out of the range! -cmd.follow.cant_reach_player=Can not reach the player, he is either in chunks that are not loaded, too far away or not reachable by a bot due to obstacles like gaps or water bodies! -cmd.follow.already_following=Already following {0}! -cmd.follow.switched=Switched to following {0}! -cmd.follow.started=Started following {0}! -cmd.follow.unsafe_enabled=Enabled us-safe walking (NOTE: The bot might die or get hurt!) -cmd.follow.note=NOTE: The bot is quite slow, you need to walk slowly and at a close distance for it to be able to keep up, kinda like when you make animals follow you by holding food in your hand. This is a limitation due to a pathfinding algorithm, we are working to get a better one. -cmd.follow.player_came_to_the_range=The player {0} came back to the range! -cmd.follow.resuming=Resuming to follow! -cmd.follow.player_left_the_range=The player {0} has left the range! -cmd.follow.pausing=Pausing! -cmd.follow.player_left=The player {0} left the server! -cmd.follow.stopping=Stopped! - # Script +botname.Script=Script bot.script.not_found=§8[MCC] [{0}] Cannot find script file: {1} bot.script.file_not_found=File not found: '{0}' bot.script.fail=Script '{0}' failed to run ({1}). bot.script.pm.loaded=Script '{0}' loaded. # ScriptScheduler +botname.ScriptScheduler=ScriptScheduler bot.scriptScheduler.loaded_task=Loaded task:\n{0} bot.scriptScheduler.no_trigger=This task will never trigger:\n{0} bot.scriptScheduler.no_action=No action for task:\n{0} @@ -709,12 +743,12 @@ bot.scriptScheduler.running_login=Login / Running action: {0} bot.scriptScheduler.task=triggeronfirstlogin: {0}\n triggeronlogin: {1}\n triggerontime: {2}\n triggeroninterval: {3}\n timevalue: {4}\n timeinterval: {5}\n action: {6} # TestBot +botname.TestBot=TestBot bot.testBot.told=Bot: {0} told me : {1} bot.testBot.said=Bot: {0} said : {1} [config] - config.load=Settings have been loaded from {0} config.load.fail=§cFailed to load settings:§r config.write.fail=§cFailed to write to settings file {0}§r diff --git a/MinecraftClient/Resources/lang/fr.ini b/MinecraftClient/Resources/lang/fr.ini index 3ab0cab983214dd5238fa908a84f24142dbce169..307b70fd060c8c6c634238cdad249f9dd304862c 100644 GIT binary patch delta 1648 zcma)6T}YE*6n@{iHrZx=bM8+Y+Y(#Wl-6CuM6C?1&`P8`bvl1ax3NvSOZ1|vF3e+n zr9^dAbfK%4bP7^NNO)zDnXp15R4NL)5WC6F_ib+e;F7Vw_nhaP=REIoz8}w}PbQ_I z-h5cHt29C4CVqU?krv`1HTd?zxKj&X?HmM)GPKPY@sI}6D#n`<8LT`1+A(lNbnI_q zGli8#!yd$v8b~iSQYS1onqvQ#OZDt>bG1Y6!BTC+4Rvc;(Dm(y$lZ_n*cmAx#n>i@ zO^Qh=IRk(C%rMb6wT|I`NvR%s!aDY#znsQTi{(_yTjW#*hXy(5zOQM_X+I0l4|&uO2pn6<-qq;!3?27nf?@#43adWATFFHh@?c)e3^=x zc`lWvLiJEayoDp38sT6+2Xolw^RSF{4XIM#=ZMS^B<&=CY6+?~VkM_oGly7kz;>+b z#W7njqZv=?QI-aH8@59CNJv1d*U|N;yBit!;U-3lMt#ZvVg-g+J$9ym(CE=PBd?lf zi$hnAso3ghraT@=*HAM|4scL8Chd8xVh3KWq!<(WpFk=?;j>7si8w($@u=gZNU(+x4j zcY|#c#|+@72ZyUcyq8?T8lGqkd&~;SnK$8;w2)SK(PeV%rfI#Xca(A~jCW;Q|BC{L z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pbjE@MlRAnJlhE7-lN{d;vj*Mb0ka(6o&=LN&#vS?P~ML|V0YF74-gM`2=vu#aFH+AdhrXRY>x+$M9 z$coY$5mA$`E19_{GKEATDk37ID1CR*vx|Msa6> zW--cK*{H8bLui}GcW+-WU{6K%RLaFF(O@@YSH+xk`HgaT*a2F#{7S{oh0}bLx{i5p z`<)SwPGsTMiMOWFJtF6zvOy~9U?pr5o;6u;wP`@bbPSttdRT`;?IMnxe68*eeKf-N zQHQ=(vAM;-gQr%dC*<5uIsI%6<@KVW-PC+RkIvQmNw=SHVYFbMq zgKP#%VY>+!BvK0LbDu4!59zV2Ekgx5zMAp8NraQYJKJ7pmIeqQ!S}NO2`7oXhmzRk zbXJx}cT@P3&{=?0(~gT2al_G`kLB0GrbN6;7O;vn67zgGLn-JxV`vVQr;ZC7JzAl1 z>iU`^i{!jv;BBELhKzLBWx~s-e*Wai6_AfK_7FUX!D!~b zWYKl9Baog=1DOS z3Nus3M%E5n)T(ySAES!*vUqv)g9g>nY?FuRyJf2-Og5^bmg(vlI+kZ*#r?t=iGKbR z%R%J9Y<}ea@hNbQWX=4iwb(LZ!$7|dFTIr=ku1kmjwJe zCPM7djT`c<)PBjK_0&>3?)94a+@6R!-RIH;!G?#u1zgj+Ks(O(Wh9<7NX6s>37G%5 z8}s_pkk+r~vBw(=lQhZk!D^hag%}((7Vnxt4;ve{7P^6)g03>zRkm6<0+l*nHMX-b1EfT6gBuZexp{RY7o&e;F} delta 241 zcmVj1zK< diff --git a/MinecraftClient/Resources/lang/zh-Hans.ini b/MinecraftClient/Resources/lang/zh-Hans.ini index fbef68787d016992e84f86661f58ff9f80526fe2..a4ac3b53747f4fc05f43fbdbe61659e3cac4b9e1 100644 GIT binary patch delta 2132 zcma)7ZERCz6n<|zW>;D_p=;NUZp~$bQLr{jB>rfua}-4#t~67&v3lE%wqa{$OD9{F ztkW7u+y~pil^8=DMUjLp>u#b6F(~{n{*X8l6Z}XH!mJvZ)#h(J7~7ytQ) zjld^bE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t}Y1D+(J=dd__xzctlHOJ0g9lr3d%3TC!szLVQ3+4LfvP zI;v-AW)_<>gYjq$HApLqtrY$lP}XhB5@~W0>BgAuMS_T=*m1A@+Y$KXnogR(cADiP$TIV;?TX|kbC?nYEuUWDh?$|c)Md8Z~1MdKSPdayc=5dDeq z@k(lXJimgO*pMhGLUZND-IQNSG8yUcGM=RO!@C(I7k-Mydo?=FnafD&=O(xo|3424 U-#Baw1mYVN)bw?41#M9N3tS)@MgRZ+ delta 380 zcmZXNze@sf7{8oEJq>;cfr}w$y zF#Pd8dfEwc3M6VAp_GKqr;PBfjK#f($yzn(k-GWXkx0=)r?m@hL((_c7TaV#Hq8<& z&bFDK#mpIH4hALZM%%DKH>838=UEnE>!vbezQ^G+#_~!pw&N)vU3zl8h%O&bxIuzrpj(?UTIV ScriptAssemblies = new(); diff --git a/MinecraftClient/Scripting/ChatBot.cs b/MinecraftClient/Scripting/ChatBot.cs index 14fefcde..1c8272b1 100644 --- a/MinecraftClient/Scripting/ChatBot.cs +++ b/MinecraftClient/Scripting/ChatBot.cs @@ -835,10 +835,11 @@ namespace MinecraftClient /// Log text to write protected void LogToConsole(object? text) { + string botName = Translations.GetOrNull("botname." + GetType().Name) ?? GetType().Name; if (_handler == null || master == null) - ConsoleIO.WriteLogLine(String.Format("[{0}] {1}", GetType().Name, text)); + ConsoleIO.WriteLogLine(String.Format("[{0}] {1}", botName, text)); else - Handler.Log.Info(String.Format("[{0}] {1}", GetType().Name, text)); + Handler.Log.Info(String.Format("[{0}] {1}", botName, text)); string logfile = Settings.Config.AppVar.ExpandVars(Config.Main.Advanced.ChatbotLogFile); if (!String.IsNullOrEmpty(logfile)) @@ -913,7 +914,10 @@ namespace MinecraftClient protected void ReconnectToTheServer(int ExtraAttempts = 3, int delaySeconds = 0) { if (Settings.Config.Logging.DebugMessages) - ConsoleIO.WriteLogLine(Translations.Get("chatbot.reconnect", GetType().Name)); + { + string botName = Translations.GetOrNull("botname." + GetType().Name) ?? GetType().Name; + ConsoleIO.WriteLogLine(Translations.Get("chatbot.reconnect", botName)); + } McClient.ReconnectionAttemptsLeft = ExtraAttempts; Program.Restart(delaySeconds); } @@ -1129,14 +1133,15 @@ namespace MinecraftClient /// protected static string GetTimestamp() { - DateTime time = DateTime.Now; - return String.Format("{0}-{1}-{2} {3}:{4}:{5}", - time.Year.ToString("0000"), - time.Month.ToString("00"), - time.Day.ToString("00"), - time.Hour.ToString("00"), - time.Minute.ToString("00"), - time.Second.ToString("00")); + return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + /// + /// Get a h:m:s timestamp representing the current system time + /// + protected static string GetShortTimestamp() + { + return DateTime.Now.ToString("HH:mm:ss"); } /// diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index fdae982b..c0115a29 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -387,6 +387,7 @@ namespace MinecraftClient { string[] sip = General.Server.Host.Split(new[] { ":", ":" }, StringSplitOptions.None); General.Server.Host = sip[0]; + InternalConfig.ServerIP = General.Server.Host; if (sip.Length > 1) { @@ -395,7 +396,10 @@ namespace MinecraftClient } } - SetServerIP(General.Server, true); + if (General.Server.Port.HasValue) + InternalConfig.ServerPort = General.Server.Port.Value; + else + SetServerIP(General.Server, true); for (int i = 0; i < Advanced.BotOwners.Count; ++i) Advanced.BotOwners[i] = ToLowerIfNeed(Advanced.BotOwners[i]); @@ -1094,7 +1098,7 @@ namespace MinecraftClient public ChatBots.DiscordBridge.Configs DiscordBridge { get { return ChatBots.DiscordBridge.Config; } - set { ChatBots.DiscordBridge.Config = value; } + set { ChatBots.DiscordBridge.Config = value; ChatBots.DiscordBridge.Config.OnSettingUpdate(); } } [TomlPrecedingComment("$config.ChatBot.Farmer$")] diff --git a/README.md b/README.md index 7d49547e..0456d50b 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ If you'd like to contribute to Minecraft Console Client, great, just fork the re Check out: [How to update or add translations for MCC](https://mccteam.github.io/guide/contibuting.html#translations). MCC now supports the following languages (Alphabetical order) : - * `de.ini` (51.34% translated) : Deutsch - German + * `de.ini` (48.28% translated) : Deutsch - German * `en.ini` : English - English - * `fr.ini` (51.34% translated) : Français (France) - French - * `ru.ini` (50.49% translated) : Русский (Russkiy) - Russian - * `vi.ini` (50.49% translated) : Tiếng Việt (Việt Nam) - Vietnamese - * `zh-Hans.ini` (95.50% translated) : 简体中文 - Chinese Simplified - * `zh-Hant.ini` (95.50% translated) : 繁體中文 - Chinese Traditional + * `fr.ini` (48.28% translated) : Français (France) - French + * `ru.ini` (47.49% translated) : Русский (Russkiy) - Russian + * `vi.ini` (47.49% translated) : Tiếng Việt (Việt Nam) - Vietnamese + * `zh-Hans.ini` (92.20% translated) : 简体中文 - Chinese Simplified + * `zh-Hant.ini` (92.20% translated) : 繁體中文 - Chinese Traditional ## Building from the source 🏗️