Upgrade AutoFishing & Bug fix

This commit is contained in:
BruceChen 2022-10-21 19:05:49 +08:00
parent a2eb3606ce
commit d4f8dd0bfb
15 changed files with 183 additions and 89 deletions

View file

@ -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<ItemType, uint> 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<KeyValuePair<ItemType, uint>> 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<int, object?> 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
};
}

View file

@ -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();

View file

@ -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()

View file

@ -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));
}
/// <summary>

View file

@ -477,20 +477,24 @@ cmd.useitem.use=Used an item
# ChatBots. Naming style: bot.<className>.<msg...>
# 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 <command name>
# 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 <cmd name> 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 <command name>
# 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 <player name|stop> [-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} <username>
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 <player name|stop> [-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

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Reflection;
namespace MinecraftClient.Scripting;
namespace MinecraftClient.Scripting;
public static class AssemblyResolver {
private static Dictionary<string, string> ScriptAssemblies = new();

View file

@ -835,10 +835,11 @@ namespace MinecraftClient
/// <param name="text">Log text to write</param>
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
/// </summary>
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");
}
/// <summary>
/// Get a h:m:s timestamp representing the current system time
/// </summary>
protected static string GetShortTimestamp()
{
return DateTime.Now.ToString("HH:mm:ss");
}
/// <summary>

View file

@ -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$")]

View file

@ -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 🏗️