This commit is contained in:
BruceChen 2022-10-07 21:49:05 +08:00
parent 77d858dc35
commit c1a04fe5bf
12 changed files with 57 additions and 27 deletions

View file

@ -39,7 +39,7 @@ namespace MinecraftClient.ChatBots
public bool Attack_Passive = false;
[TomlInlineComment("$config.ChatBot.AutoAttack.List_Mode$")]
public ListType List_Mode = ListType.blacklist;
public ListType List_Mode = ListType.whitelist;
[TomlInlineComment("$config.ChatBot.AutoAttack.Entites_List$")]
public List<EntityType> Entites_List = new() { EntityType.Zombie, EntityType.Cow };

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MinecraftClient.Inventory;
using MinecraftClient.Mapping;
using Tomlet.Attributes;
@ -298,8 +299,10 @@ namespace MinecraftClient.ChatBots
switch (args[0])
{
case "list":
string names = string.Join(", ", Config.Recipes.ToList());
return Translations.Get("bot.autoCraft.cmd.list", Config.Recipes.Length, names);
StringBuilder nameList = new();
foreach (RecipeConfig recipe in Config.Recipes)
nameList.Append(recipe.Name).Append(", ");
return Translations.Get("bot.autoCraft.cmd.list", Config.Recipes.Length, nameList.ToString());
case "start":
if (args.Length >= 2)
{
@ -435,7 +438,7 @@ namespace MinecraftClient.ChatBots
Dictionary<int, ItemType> materials = new();
for (int i = 0; i < recipeConfig.Slots.Length; ++i)
if (recipeConfig.Slots[i] != ItemType.Null)
materials[i] = recipeConfig.Slots[i];
materials[i + 1] = recipeConfig.Slots[i];
ItemType ResultItem = recipeConfig.Result;

View file

@ -31,7 +31,7 @@ namespace MinecraftClient.ChatBots
public string[] Kick_Messages = new string[] { "Connection has been lost", "Server is restarting", "Server is full", "Too Many people" };
[NonSerialized]
public int _DelayMin, _DelayMax;
public static int _BotRecoAttempts = 0;
public void OnSettingUpdate()
{
@ -43,9 +43,6 @@ namespace MinecraftClient.ChatBots
if (Delay.min > Delay.max)
(Delay.min, Delay.max) = (Delay.max, Delay.min);
_DelayMin = (int)Math.Round(Delay.min * 10);
_DelayMax = (int)Math.Round(Delay.max * 10);
if (Retries == -1)
Retries = int.MaxValue;
@ -100,7 +97,7 @@ namespace MinecraftClient.ChatBots
{
LogDebugToConsoleTranslated("bot.autoRelog.ignore_user_logout");
}
else
else if (Config.Retries < 0 || Configs._BotRecoAttempts < Config.Retries)
{
message = GetVerbatim(message);
string comp = message.ToLower();
@ -109,6 +106,7 @@ namespace MinecraftClient.ChatBots
if (Config.Ignore_Kick_Message)
{
Configs._BotRecoAttempts++;
LaunchDelayedReconnection(null);
return true;
}
@ -117,6 +115,7 @@ namespace MinecraftClient.ChatBots
{
if (comp.Contains(msg))
{
Configs._BotRecoAttempts++;
LaunchDelayedReconnection(msg);
return true;
}
@ -130,7 +129,7 @@ namespace MinecraftClient.ChatBots
private void LaunchDelayedReconnection(string? msg)
{
int delay = random.Next(Config._DelayMin, Config._DelayMax);
int delay = random.Next((int)Config.Delay.min, (int)Config.Delay.max);
LogDebugToConsoleTranslated(String.IsNullOrEmpty(msg) ? "bot.autoRelog.reconnect_always" : "bot.autoRelog.reconnect", msg);
LogToConsoleTranslated("bot.autoRelog.wait", delay);
System.Threading.Thread.Sleep(delay * 1000);

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using MinecraftClient.Mapping;
using MinecraftClient.Protocol.Handlers;

View file

@ -32,16 +32,16 @@ namespace MinecraftClient.Commands
sb.Append(World.GetChunkLoadingStatus(handler.GetWorld()));
sb.Append('\n');
sb.Append(String.Format("Current location{0}, chunk: ({1}, {2}).\n", current, current.ChunkX, current.ChunkZ));
sb.AppendLine(Translations.Get("cmd.chunk.current", current, current.ChunkX, current.ChunkZ));
if (markedChunkPos != null)
{
sb.Append("Marked location: ");
sb.Append(Translations.Get("cmd.chunk.marked"));
if (args.Length == 1 + 3)
sb.Append(String.Format("X:{0:0.00} Y:{1:0.00} Z:{2:0.00}, ",
double.Parse(args[1], NumberStyles.Any, CultureInfo.CurrentCulture),
double.Parse(args[2], NumberStyles.Any, CultureInfo.CurrentCulture),
double.Parse(args[3], NumberStyles.Any, CultureInfo.CurrentCulture)));
sb.Append(String.Format("chunk: ({0}, {1}).\n", markChunkX, markChunkZ));
sb.AppendLine(Translations.Get("cmd.chunk.chunk_pos", markChunkX, markChunkZ));;
}
int consoleHeight = Math.Max(Console.BufferHeight - 2, 25);
@ -127,7 +127,7 @@ namespace MinecraftClient.Commands
if (markedChunkPos != null &&
(((Math.Max(bottomMost, markChunkZ) - Math.Min(topMost, markChunkZ) + 1) > consoleHeight) ||
((Math.Max(rightMost, markChunkX) - Math.Min(leftMost, markChunkX) + 1) > consoleWidth)))
sb.Append("§x§0Since the marked chunk is outside the graph, it will not be displayed!§r\n");
sb.AppendLine(Translations.Get("cmd.chunk.outside"));
else
{
topMost = Math.Min(topMost, markChunkZ);
@ -165,8 +165,7 @@ namespace MinecraftClient.Commands
sb.Append('\n');
}
sb.Append("Player:§z §r, MarkedChunk:§w §r, ");
sb.Append(string.Format("NotReceived:{0}, Loading:{1}, Loaded:{2}", chunkStatusStr[0], chunkStatusStr[1], chunkStatusStr[2]));
sb.AppendLine(Translations.Get("cmd.chunk.icon", "§z §r", "§w §r", chunkStatusStr[0], chunkStatusStr[1], chunkStatusStr[2]));
return sb.ToString();
}
else if (args[0] == "setloading") // For debugging
@ -174,7 +173,7 @@ namespace MinecraftClient.Commands
Tuple<int, int>? chunkPos = ParseChunkPos(args);
if (chunkPos != null)
{
handler.Log.Info("§x§0This command is used for debugging, make sure you know what you are doing.§r");
handler.Log.Info(Translations.Get("cmd.chunk.for_debug"));
World world = handler.GetWorld();
(int chunkX, int chunkZ) = chunkPos;
ChunkColumn? chunkColumn = world[chunkX, chunkZ];
@ -191,7 +190,7 @@ namespace MinecraftClient.Commands
Tuple<int, int>? chunkPos = ParseChunkPos(args);
if (chunkPos != null)
{
handler.Log.Info("§x§0This command is used for debugging, make sure you know what you are doing.§r");
handler.Log.Info(Translations.Get("cmd.chunk.for_debug"));
World world = handler.GetWorld();
(int chunkX, int chunkZ) = chunkPos;
ChunkColumn? chunkColumn = world[chunkX, chunkZ];
@ -208,7 +207,7 @@ namespace MinecraftClient.Commands
Tuple<int, int>? chunkPos = ParseChunkPos(args);
if (chunkPos != null)
{
handler.Log.Info("§x§0This command is used for debugging, make sure you know what you are doing.§r");
handler.Log.Info(Translations.Get("cmd.chunk.for_debug"));
World world = handler.GetWorld();
(int chunkX, int chunkZ) = chunkPos;
world[chunkX, chunkZ] = null;

View file

@ -5,7 +5,6 @@ using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

View file

@ -243,6 +243,7 @@ namespace MinecraftClient.Protocol.Handlers
}
catch (ObjectDisposedException) { }
catch (OperationCanceledException) { }
catch (NullReferenceException) { }
if (cancelToken.IsCancellationRequested)
return;

View file

@ -237,6 +237,12 @@ cmd.changeSlot.fail=Could not change slot
# Chunk
cmd.chunk.desc=Displays the chunk loading status.\nChange EnableEmoji=false in the settings if the display is confusing.
cmd.chunk.current=Current location{0}, chunk: ({1}, {2}).
cmd.chunk.marked=Marked location:
cmd.chunk.chunk_pos=chunk: ({0}, {1}).
cmd.chunk.outside=§x§0Since the marked chunk is outside the graph, it will not be displayed!§r
cmd.chunk.icon=Player:{0}, MarkedChunk:{1}, NotReceived:{2}, Loading:{3}, Loaded:{4}
cmd.chunk.for_debug=§x§0This command is used for debugging, make sure you know what you are doing.§r
# Connect
cmd.connect.desc=connect to the specified server.

View file

@ -237,6 +237,12 @@ cmd.changeSlot.fail=无法变更栏位
# Chunk
cmd.chunk.desc=显示区块加载状态。\n如果显示错乱竟在设置中更改 EnableEmoji=false 。
cmd.chunk.current=当前位置:{0},所在区块:({1}, {2})。
cmd.chunk.marked=标记的位置:
cmd.chunk.chunk_pos=区块:({0}, {1})。
cmd.chunk.outside=§x§0由于被标记的区块距离玩家太远它不会被显示在图中§r
cmd.chunk.icon=玩家:{0},标记的区块:{1},未收到:{2},加载中:{3},已加载:{4}
cmd.chunk.for_debug=§x§0此命令仅用于调试使用确保你已经了解执行该命令会造成的影响。§r
# Connect
cmd.connect.desc=连接到指定的服务器。

View file

@ -237,6 +237,12 @@ cmd.changeSlot.fail=無法變更欄位
# Chunk
cmd.chunk.desc=顯示區塊載入狀態。\n如果顯示錯亂竟在設定中更改 EnableEmoji=false 。
cmd.chunk.current=當前位置:{0},所在區塊:({1}, {2})。
cmd.chunk.marked=標記的位置:
cmd.chunk.chunk_pos=區塊:({0}, {1})。
cmd.chunk.outside=§x§0由於被標記的區塊距離玩家太遠它不會被顯示在圖中§r
cmd.chunk.icon=玩家:{0},標記的區塊:{1},未收到:{2},載入中:{3},已載入:{4}
cmd.chunk.for_debug=§x§0此命令僅用於除錯使用確保你已經瞭解執行該命令會造成的影響。§r
# Connect
cmd.connect.desc=連線到指定的伺服器。

View file

@ -15,7 +15,7 @@ namespace MinecraftClient
/// </remarks>
public static class Translations
{
private static readonly Dictionary<string, string> translations = new();
private static Dictionary<string, string> translations;
private static readonly string translationFilePath = "lang" + Path.DirectorySeparatorChar + "mcc";
private static readonly Regex translationKeyRegex = new(@"\(\[(.*?)\]\)", RegexOptions.Compiled); // Extract string inside ([ ])
@ -89,6 +89,16 @@ namespace MinecraftClient
return Get(m.Groups[1].Value);
}
/// <summary>
/// Initialize translations depending on system language.
/// English is the default for all unknown system languages.
/// </summary>
static Translations()
{
string[] engLang = DefaultConfigResource.Translation_en.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); // use embedded translations
translations = ParseTranslationContent(engLang);
}
public static Tuple<string, string[]> GetTranslationPriority()
{
string gameLanguage = "en_gb";
@ -579,6 +589,8 @@ namespace MinecraftClient
/// </summary>
public static void LoadTranslationFile(string[] languageList)
{
translations = new();
/*
* External translation files
* These files are loaded from the installation directory as:

View file

@ -6,7 +6,7 @@
[Documentation](https://mccteam.github.io/) | [Download](#download) | [Installation](https://mccteam.github.io/guide/installation.html) | [Configuration](https://mccteam.github.io/guide/configuration.html) | [Usage](https://mccteam.github.io/guide/usage.html)
[English](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README.md) | [Nederlands](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-nl.md) | [Türkçe](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-tr.md) | [Tiếng Việt](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-vi-vn.md) | [简体中文](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-zh-Hans.md)
[English](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README.md) | [Nederlands](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-nl.md) | [Српски](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-sr.md) | [Türkçe](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-tr.md) | [Tiếng Việt](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-vi-vn.md) | [简体中文](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/README-zh-Hans.md)
[![GitHub Actions build status](https://github.com/MCCTeam/Minecraft-Console-Client/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/MCCTeam/Minecraft-Console-Client/releases/latest) <a href="https://discord.gg/sfBv4TtpC9"><img src="https://img.shields.io/discord/1018553894831403028?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
@ -50,11 +50,11 @@ 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` (57.30% translated) : Deutsch - German
* `de.ini` (57.12% translated) : Deutsch - German
* `en.ini` : English - English
* `fr.ini` (57.30% translated) : Français (France) - French
* `ru.ini` (56.36% translated) : Русский (Russkiy) - Russian
* `vi.ini` (56.36% translated) : Tiếng Việt (Việt Nam) - Vietnamese
* `fr.ini` (57.12% translated) : Français (France) - French
* `ru.ini` (56.18% translated) : Русский (Russkiy) - Russian
* `vi.ini` (56.18% translated) : Tiếng Việt (Việt Nam) - Vietnamese
* `zh-Hans.ini` (100.00% translated) : 简体中文 - Chinese Simplified
* `zh-Hant.ini` (100.00% translated) : 繁體中文 - Chinese Traditional