This commit is contained in:
BruceChen 2022-10-16 20:37:07 +08:00
parent 8d15acaef3
commit db6d6c80bf
22 changed files with 130 additions and 152 deletions

View file

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
using MinecraftClient.Inventory; using MinecraftClient.Inventory;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Xml.Linq;
using Tomlet.Attributes; using Tomlet.Attributes;
using static MinecraftClient.ChatBots.ScriptScheduler.Configs; using static MinecraftClient.ChatBots.ScriptScheduler.Configs;
@ -249,7 +250,7 @@ namespace MinecraftClient.ChatBots
task.Trigger_On_Login, task.Trigger_On_Login,
task.Trigger_On_Times.Enable, task.Trigger_On_Times.Enable,
task.Trigger_On_Interval.Enable, task.Trigger_On_Interval.Enable,
task.Trigger_On_Times.Times, string.Join(", ", Array.ConvertAll(task.Trigger_On_Times.Times, time => time.ToString())),
task.Trigger_On_Interval.MinTime + '-' + task.Trigger_On_Interval.MaxTime, task.Trigger_On_Interval.MinTime + '-' + task.Trigger_On_Interval.MaxTime,
task.Action task.Action
); );

View file

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using MinecraftClient.Inventory; using MinecraftClient.Inventory;

View file

@ -8,11 +8,10 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace MinecraftClient namespace MinecraftClient {
{
using System; using System;
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
@ -23,52 +22,44 @@ namespace MinecraftClient
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class DefaultConfigResource internal class DefaultConfigResource {
{
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal DefaultConfigResource() internal DefaultConfigResource() {
{
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager internal static global::System.Resources.ResourceManager ResourceManager {
{ get {
get if (object.ReferenceEquals(resourceMan, null)) {
{
if (object.ReferenceEquals(resourceMan, null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClient.DefaultConfigResource", typeof(DefaultConfigResource).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClient.DefaultConfigResource", typeof(DefaultConfigResource).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
} }
} }
/// <summary> /// <summary>
/// Overrides the current thread's CurrentUICulture property for all /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture internal static global::System.Globalization.CultureInfo Culture {
{ get {
get
{
return resourceCulture; return resourceCulture;
} }
set set {
{
resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Brewing Stand ║ ///║ Brewing Stand ║
@ -84,14 +75,12 @@ namespace MinecraftClient
///║║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║12 ║13 ║║ ///║║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║12 ║13 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;. ///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_BrewingStand internal static string ContainerType_BrewingStand {
{ get {
get
{
return ResourceManager.GetString("ContainerType_BrewingStand", resourceCulture); return ResourceManager.GetString("ContainerType_BrewingStand", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Crafting ║ ///║ Crafting ║
@ -107,21 +96,33 @@ namespace MinecraftClient
///║║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║18 ║║ ///║║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║18 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;. ///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Crafting internal static string ContainerType_Crafting {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Crafting", resourceCulture); return ResourceManager.GetString("ContainerType_Crafting", resourceCulture);
} }
} }
internal static string ContainerType_EnchantingTable
{ /// <summary>
get /// Looks up a localized string similar to ╔═════════════════════════════════════╗
{ ///║ Enchant ║
///║ ╔════════════════════╗ ║
///║ ║ Top ║ ║
///║ ╔═══╦═══╗ ╠════════════════════╣ ║
///║ ║ 0 ║ 1 ║ ║ Middle ║ ║
///║ ╚═══╩═══╝ ╠════════════════════╣ ║
///║ ║ Bottom ║ ║
///║ ╚════════════════════╝ ║
///║ Inventory ║
///║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║
///║║ 2 ║ 3 ║ 4 ║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary>
internal static string ContainerType_EnchantingTable {
get {
return ResourceManager.GetString("ContainerType_EnchantingTable", resourceCulture); return ResourceManager.GetString("ContainerType_EnchantingTable", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Container ║ ///║ Container ║
@ -137,14 +138,12 @@ namespace MinecraftClient
///║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ ///║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║
///║║ 3 ║ 4 ║ 5 ║ 6 ║ 7 [rest of string was truncated]&quot;;. ///║║ 3 ║ 4 ║ 5 ║ 6 ║ 7 [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Furnace internal static string ContainerType_Furnace {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Furnace", resourceCulture); return ResourceManager.GetString("ContainerType_Furnace", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Container ║ ///║ Container ║
@ -160,14 +159,12 @@ namespace MinecraftClient
///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║ ///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;. ///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Generic_3x3 internal static string ContainerType_Generic_3x3 {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Generic_3x3", resourceCulture); return ResourceManager.GetString("ContainerType_Generic_3x3", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Container ║ ///║ Container ║
@ -183,14 +180,12 @@ namespace MinecraftClient
///║║27 ║28 ║29 ║30 ║31 ║32 ║33 ║34 ║35 ║║ ///║║27 ║28 ║29 ║30 ║31 ║32 ║33 ║34 ║35 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;. ///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Generic_9x3 internal static string ContainerType_Generic_9x3 {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Generic_9x3", resourceCulture); return ResourceManager.GetString("ContainerType_Generic_9x3", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Container ║ ///║ Container ║
@ -206,14 +201,12 @@ namespace MinecraftClient
///║║36 ║37 ║38 ║39 ║40 ║41 ║42 ║43 ║44 ║║ ///║║36 ║37 ║38 ║39 ║40 ║41 ║42 ║43 ║44 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;. ///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Generic_9x6 internal static string ContainerType_Generic_9x6 {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Generic_9x6", resourceCulture); return ResourceManager.GetString("ContainerType_Generic_9x6", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Repair &amp; Disenchant ║ ///║ Repair &amp; Disenchant ║
@ -229,14 +222,12 @@ namespace MinecraftClient
///║ ╚══╝ ╚══╝ ║ ///║ ╚══╝ ╚══╝ ║
///║ [rest of string was truncated]&quot;;. ///║ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Grindstone internal static string ContainerType_Grindstone {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Grindstone", resourceCulture); return ResourceManager.GetString("ContainerType_Grindstone", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║ Container ║ ///║ Container ║
@ -252,14 +243,12 @@ namespace MinecraftClient
///║║23 ║24 ║25 ║26 ║27 ║28 ║29 ║30 ║31 ║║ ///║║23 ║24 ║25 ║26 ║27 ║28 ║29 ║30 ║31 ║║
///║╚═══╩═══╩═══╩═══╩══ [rest of string was truncated]&quot;;. ///║╚═══╩═══╩═══╩═══╩══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_Hopper internal static string ContainerType_Hopper {
{ get {
get
{
return ResourceManager.GetString("ContainerType_Hopper", resourceCulture); return ResourceManager.GetString("ContainerType_Hopper", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ╔═════════════════════════════════════╗ /// Looks up a localized string similar to ╔═════════════════════════════════════╗
///║╔═══╦═══════════╗ ║ ///║╔═══╦═══════════╗ ║
@ -275,14 +264,12 @@ namespace MinecraftClient
///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║ ///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;. ///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string ContainerType_PlayerInventory internal static string ContainerType_PlayerInventory {
{ get {
get
{
return ResourceManager.GetString("ContainerType_PlayerInventory", resourceCulture); return ResourceManager.GetString("ContainerType_PlayerInventory", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -299,14 +286,12 @@ namespace MinecraftClient
///mcc.session_invalid=§8Gespeicherte Session ungültig oder abgelaufen. ///mcc.session_invalid=§8Gespeicherte Session ungültig oder abgelaufen.
///mcc.session_valid=§8Gespeicherte Ses [rest of string was truncated]&quot;;. ///mcc.session_valid=§8Gespeicherte Ses [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_de internal static string Translation_de {
{ get {
get
{
return ResourceManager.GetString("Translation_de", resourceCulture); return ResourceManager.GetString("Translation_de", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -321,14 +306,12 @@ namespace MinecraftClient
///mcc.password_hidden=Password(invisible): {0} ///mcc.password_hidden=Password(invisible): {0}
///mcc.off [rest of string was truncated]&quot;;. ///mcc.off [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_en internal static string Translation_en {
{ get {
get
{
return ResourceManager.GetString("Translation_en", resourceCulture); return ResourceManager.GetString("Translation_en", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -345,14 +328,12 @@ namespace MinecraftClient
///mcc.session_invalid=§8Le cache de la session est invalide ou a expiré. ///mcc.session_invalid=§8Le cache de la session est invalide ou a expiré.
///mcc.session_va [rest of string was truncated]&quot;;. ///mcc.session_va [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_fr internal static string Translation_fr {
{ get {
get
{
return ResourceManager.GetString("Translation_fr", resourceCulture); return ResourceManager.GetString("Translation_fr", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -369,14 +350,12 @@ namespace MinecraftClient
///mcc.session_invalid=§8Кэшированная сессия недействительна или истекла. ///mcc.session_invalid=§8Кэшированная сессия недействительна или истекла.
///mcc.session_valid=§8Кэшированная се [rest of string was truncated]&quot;;. ///mcc.session_valid=§8Кэшированная се [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_ru internal static string Translation_ru {
{ get {
get
{
return ResourceManager.GetString("Translation_ru", resourceCulture); return ResourceManager.GetString("Translation_ru", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -394,14 +373,12 @@ namespace MinecraftClient
///mcc.session_valid=§8Phiên vẫn còn hợp lệ cho {0}. ///mcc.session_valid=§8Phiên vẫn còn hợp lệ cho {0}.
///mcc.profile_ke [rest of string was truncated]&quot;;. ///mcc.profile_ke [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_vi internal static string Translation_vi {
{ get {
get
{
return ResourceManager.GetString("Translation_vi", resourceCulture); return ResourceManager.GetString("Translation_vi", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -420,14 +397,12 @@ namespace MinecraftClient
///mcc.profile_key_invalid=§8缓存的聊天签名密钥需要刷新。 ///mcc.profile_key_invalid=§8缓存的聊天签名密钥需要刷新。
///mcc.profile_key_valid=§8{0 [rest of string was truncated]&quot;;. ///mcc.profile_key_valid=§8{0 [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_zh_Hans internal static string Translation_zh_Hans {
{ get {
get
{
return ResourceManager.GetString("Translation_zh_Hans", resourceCulture); return ResourceManager.GetString("Translation_zh_Hans", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to [mcc] /// Looks up a localized string similar to [mcc]
///# Messages from MCC itself ///# Messages from MCC itself
@ -446,10 +421,8 @@ namespace MinecraftClient
///mcc.profile_key_invalid=§8快取的聊天簽名金鑰需要重新整理。 ///mcc.profile_key_invalid=§8快取的聊天簽名金鑰需要重新整理。
///mcc.profile_key_valid [rest of string was truncated]&quot;;. ///mcc.profile_key_valid [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string Translation_zh_Hant internal static string Translation_zh_Hant {
{ get {
get
{
return ResourceManager.GetString("Translation_zh_Hant", resourceCulture); return ResourceManager.GetString("Translation_zh_Hant", resourceCulture);
} }
} }

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using MinecraftClient.Commands;
using MinecraftClient.Protocol.Handlers; using MinecraftClient.Protocol.Handlers;
namespace MinecraftClient.Inventory namespace MinecraftClient.Inventory

View file

@ -4,7 +4,6 @@ using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Transactions;
using MinecraftClient.ChatBots; using MinecraftClient.ChatBots;
using MinecraftClient.Inventory; using MinecraftClient.Inventory;
using MinecraftClient.Logger; using MinecraftClient.Logger;

View file

@ -397,19 +397,19 @@ namespace MinecraftClient
//Asking the user to type in missing data such as Username and Password //Asking the user to type in missing data such as Username and Password
bool useBrowser = Config.Main.General.AccountType == LoginType.microsoft && Config.Main.General.Method == LoginMethod.browser; bool useBrowser = Config.Main.General.AccountType == LoginType.microsoft && Config.Main.General.Method == LoginMethod.browser;
if (string.IsNullOrEmpty(Config.Main.General.Account.Login) && !useBrowser) if (string.IsNullOrEmpty(InternalConfig.Login) && !useBrowser)
{ {
ConsoleIO.WriteLine(ConsoleIO.BasicIO ? Translations.Get("mcc.login_basic_io") : Translations.Get("mcc.login")); ConsoleIO.WriteLine(ConsoleIO.BasicIO ? Translations.Get("mcc.login_basic_io") : Translations.Get("mcc.login"));
Config.Main.General.Account.Login = ConsoleIO.ReadLine().Trim(); InternalConfig.Login = ConsoleIO.ReadLine().Trim();
if (string.IsNullOrEmpty(Config.Main.General.Account.Login)) if (string.IsNullOrEmpty(InternalConfig.Login))
{ {
HandleFailure(Translations.Get("error.login.blocked"), false, ChatBot.DisconnectReason.LoginRejected); HandleFailure(Translations.Get("error.login.blocked"), false, ChatBot.DisconnectReason.LoginRejected);
return; return;
} }
} }
InternalConfig.Username = Config.Main.General.Account.Login; InternalConfig.Username = InternalConfig.Login;
if (string.IsNullOrEmpty(Config.Main.General.Account.Password) && !useBrowser && if (string.IsNullOrEmpty(Config.Main.General.Account.Password) && !useBrowser &&
(Config.Main.Advanced.SessionCache == CacheType.none || !SessionCache.Contains(Settings.ToLowerIfNeed(Config.Main.General.Account.Login)))) (Config.Main.Advanced.SessionCache == CacheType.none || !SessionCache.Contains(Settings.ToLowerIfNeed(InternalConfig.Login))))
{ {
RequestPassword(); RequestPassword();
} }
@ -427,7 +427,7 @@ namespace MinecraftClient
/// </summary> /// </summary>
private static void RequestPassword() private static void RequestPassword()
{ {
ConsoleIO.WriteLine(ConsoleIO.BasicIO ? Translations.Get("mcc.password_basic_io", Config.Main.General.Account.Login) + "\n" : Translations.Get("mcc.password")); ConsoleIO.WriteLine(ConsoleIO.BasicIO ? Translations.Get("mcc.password_basic_io", InternalConfig.Login) + "\n" : Translations.Get("mcc.password"));
string? password = ConsoleIO.BasicIO ? Console.ReadLine() : ConsoleIO.ReadPassword(); string? password = ConsoleIO.BasicIO ? Console.ReadLine() : ConsoleIO.ReadPassword();
if (password == null || password == string.Empty) { password = "-"; } if (password == null || password == string.Empty) { password = "-"; }
InternalConfig.Password = password; InternalConfig.Password = password;
@ -445,7 +445,7 @@ namespace MinecraftClient
ProtocolHandler.LoginResult result = ProtocolHandler.LoginResult.LoginRequired; ProtocolHandler.LoginResult result = ProtocolHandler.LoginResult.LoginRequired;
string loginLower = Settings.ToLowerIfNeed(Config.Main.General.Account.Login); string loginLower = Settings.ToLowerIfNeed(InternalConfig.Login);
if (InternalConfig.Password == "-") if (InternalConfig.Password == "-")
{ {
Translations.WriteLineFormatted("mcc.offline"); Translations.WriteLineFormatted("mcc.offline");
@ -488,7 +488,7 @@ namespace MinecraftClient
if (result != ProtocolHandler.LoginResult.Success) if (result != ProtocolHandler.LoginResult.Success)
{ {
Translations.WriteLine("mcc.connecting", Config.Main.General.AccountType == LoginType.mojang ? "Minecraft.net" : "Microsoft"); Translations.WriteLine("mcc.connecting", Config.Main.General.AccountType == LoginType.mojang ? "Minecraft.net" : "Microsoft");
result = ProtocolHandler.GetLogin(Config.Main.General.Account.Login, InternalConfig.Password, Config.Main.General.AccountType, out session); result = ProtocolHandler.GetLogin(InternalConfig.Login, InternalConfig.Password, Config.Main.General.AccountType, out session);
} }
if (result == ProtocolHandler.LoginResult.Success && Config.Main.Advanced.SessionCache != CacheType.none) if (result == ProtocolHandler.LoginResult.Success && Config.Main.Advanced.SessionCache != CacheType.none)

View file

@ -446,9 +446,9 @@ namespace MinecraftClient.Protocol.Handlers
else else
entityType = entityPalette.FromId(ReadNextByte(cache), living); entityType = entityPalette.FromId(ReadNextByte(cache), living);
Double entityX = ReadNextDouble(cache); double entityX = ReadNextDouble(cache);
Double entityY = ReadNextDouble(cache); double entityY = ReadNextDouble(cache);
Double entityZ = ReadNextDouble(cache); double entityZ = ReadNextDouble(cache);
byte entityPitch = ReadNextByte(cache); byte entityPitch = ReadNextByte(cache);
byte entityYaw = ReadNextByte(cache); byte entityYaw = ReadNextByte(cache);

View file

@ -535,7 +535,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
session.ServerIDhash = serverIDhash; session.ServerIDhash = serverIDhash;
session.ServerPublicKey = serverPublicKey; session.ServerPublicKey = serverPublicKey;
SessionCache.Store(Config.Main.General.Account.Login.ToLower(), session); SessionCache.Store(InternalConfig.Login.ToLower(), session);
} }
else else
{ {

View file

@ -1974,7 +1974,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
session.ServerIDhash = serverIDhash; session.ServerIDhash = serverIDhash;
session.ServerPublicKey = serverPublicKey; session.ServerPublicKey = serverPublicKey;
SessionCache.Store(Config.Main.General.Account.Login.ToLower(), session); SessionCache.Store(InternalConfig.Login.ToLower(), session);
} }
else else
{ {

View file

@ -603,7 +603,7 @@ namespace MinecraftClient.Protocol
session.PlayerID = profile.UUID; session.PlayerID = profile.UUID;
session.ID = accessToken; session.ID = accessToken;
session.RefreshToken = msaResponse.RefreshToken; session.RefreshToken = msaResponse.RefreshToken;
Config.Main.General.Account.Login = msaResponse.Email; InternalConfig.Login = msaResponse.Email;
return LoginResult.Success; return LoginResult.Success;
} }
else else

View file

@ -1,4 +1,4 @@
[mcc] [mcc]
# Messages from MCC itself # Messages from MCC itself
mcc.help_us_translate=Help us translate MCC: {0} mcc.help_us_translate=Help us translate MCC: {0}
mcc.run_with_default_settings=\nMCC is running with default settings. mcc.run_with_default_settings=\nMCC is running with default settings.

View file

@ -45,6 +45,8 @@ namespace MinecraftClient
public static ushort ServerPort = 25565; public static ushort ServerPort = 25565;
public static string Login = string.Empty;
public static string Username = string.Empty; public static string Username = string.Empty;
public static string Password = string.Empty; public static string Password = string.Empty;
@ -243,7 +245,7 @@ namespace MinecraftClient
switch (positionalIndex) switch (positionalIndex)
{ {
case 0: case 0:
Config.Main.General.Account.Login = argument; InternalConfig.Login = argument;
break; break;
case 1: case 1:
InternalConfig.Password = argument; InternalConfig.Password = argument;
@ -360,6 +362,7 @@ namespace MinecraftClient
General.Account.Login ??= string.Empty; General.Account.Login ??= string.Empty;
General.Account.Password ??= string.Empty; General.Account.Password ??= string.Empty;
InternalConfig.Login = General.Account.Login;
General.Server.Host ??= string.Empty; General.Server.Host ??= string.Empty;
@ -841,7 +844,7 @@ namespace MinecraftClient
switch (varname_lower) switch (varname_lower)
{ {
case "username": result.Append(InternalConfig.Username); break; case "username": result.Append(InternalConfig.Username); break;
case "login": result.Append(Settings.Config.Main.General.Account.Login); break; case "login": result.Append(InternalConfig.Login); break;
case "serverip": result.Append(InternalConfig.ServerIP); break; case "serverip": result.Append(InternalConfig.ServerIP); break;
case "serverport": result.Append(InternalConfig.ServerPort); break; case "serverport": result.Append(InternalConfig.ServerPort); break;
case "datetime": case "datetime":

View file

@ -659,17 +659,21 @@ namespace MinecraftClient
string[] transEn = DefaultConfigResource.ResourceManager.GetString("Translation_en")! string[] transEn = DefaultConfigResource.ResourceManager.GetString("Translation_en")!
.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); .Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
foreach (string lang in new string[] { "de", "fr", "ru", "vi", "zh_Hans", "zh_Hant" }) foreach (string lang in new string[] { "de", "fr", "ru", "vi", "zh-Hans", "zh-Hant" })
{ {
Dictionary<string, string> trans = ParseTranslationContent( Dictionary<string, string> trans = ParseTranslationContent(
DefaultConfigResource.ResourceManager.GetString("Translation_" + lang)! DefaultConfigResource.ResourceManager.GetString("Translation_" + lang.Replace('-', '_'), System.Globalization.CultureInfo.InvariantCulture)!
.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None) .Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)
); );
string fileName = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + translationFilePath + Path.DirectorySeparatorChar + lang + ".ini"; string fileName = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + translationFilePath + Path.DirectorySeparatorChar + lang + ".ini";
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
string backupFilePath = Path.ChangeExtension(fileName, ".backup.ini"); string backupFilePath = Path.ChangeExtension(fileName, ".backup.ini");
try { File.Copy(fileName, backupFilePath, true); } try
{
File.Copy(fileName, backupFilePath, true);
File.Delete(fileName);
}
catch (Exception ex) catch (Exception ex)
{ {
ConsoleIO.WriteLineFormatted(Translations.TryGet("config.backup.fail", backupFilePath)); ConsoleIO.WriteLineFormatted(Translations.TryGet("config.backup.fail", backupFilePath));
@ -677,7 +681,7 @@ namespace MinecraftClient
return; return;
} }
} }
using FileStream file = File.OpenWrite(fileName); StringBuilder sb = new();
int total = 0, translated = 0; int total = 0, translated = 0;
for (int i = 0; i < transEn.Length; ++i) for (int i = 0; i < transEn.Length; ++i)
{ {
@ -685,16 +689,15 @@ namespace MinecraftClient
int index = transEn[i].IndexOf('='); int index = transEn[i].IndexOf('=');
if (line.Length < 3 || !char.IsLetterOrDigit(line[0]) || index == -1 || line.Length <= (index + 1)) if (line.Length < 3 || !char.IsLetterOrDigit(line[0]) || index == -1 || line.Length <= (index + 1))
{ {
file.Write(Encoding.UTF8.GetBytes(line)); sb.Append(line);
} }
else else
{ {
string key = line[..index]; string key = line[..index];
file.Write(Encoding.UTF8.GetBytes(key)); sb.Append(key).Append('=');
file.Write(Encoding.UTF8.GetBytes("="));
if (trans.TryGetValue(key, out string? value)) if (trans.TryGetValue(key, out string? value))
{ {
file.Write(Encoding.UTF8.GetBytes(value.Replace("\n", "\\n"))); sb.Append(value.Replace("\n", "\\n"));
++total; ++total;
++translated; ++translated;
} }
@ -703,8 +706,9 @@ namespace MinecraftClient
++total; ++total;
} }
} }
file.Write(Encoding.UTF8.GetBytes(Environment.NewLine)); sb.AppendLine();
} }
File.WriteAllText(fileName, sb.ToString(), Encoding.Unicode);
ConsoleIO.WriteLine(string.Format("Language {0}: Translated {1} of {2}, {3:0.00}%", lang, translated, total, 100.0 * (double)translated / total)); ConsoleIO.WriteLine(string.Format("Language {0}: Translated {1} of {2}, {3:0.00}%", lang, translated, total, 100.0 * (double)translated / total));
} }
} }

View file

@ -48,12 +48,13 @@
请查看:[如何为MCC添加或更新翻译](https://mccteam.github.io/guide/contibuting.html#translations)。 请查看:[如何为MCC添加或更新翻译](https://mccteam.github.io/guide/contibuting.html#translations)。
MCC 现在支持这些语言(按字母顺序排列): MCC 现在支持这些语言(按字母顺序排列):
* `de.ini` : Deutsch - German * `de.ini`: Deutsch - German
* `en.ini` : English - English * `en.ini`: English - English
* `fr.ini` : Français (France) - French * `fr.ini`: Français (France) - French
* `ru.ini` : Русский (Russkiy) - Russian * `ru.ini`: Русский (Russkiy) - Russian
* `vi.ini` : Tiếng Việt (Việt Nam) - Vietnamese * `vi.ini`: Tiếng Việt (Việt Nam) - Vietnamese
* `zh-Hans.ini` : 简体中文(中国大陆) - Chinese Simplified (China; Mandarin) * `zh-Hans.ini`: 简体中文 - Chinese Simplified
* `zh-Hant.ini`: 繁體中文 - Chinese Traditional
## 从源码构建 🏗️ ## 从源码构建 🏗️

View file

@ -50,13 +50,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). 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) : MCC now supports the following languages (Alphabetical order) :
* `de.ini` (54.40% translated) : Deutsch - German * `de.ini` (49.19% translated) : Deutsch - German
* `en.ini` : English - English * `en.ini` : English - English
* `fr.ini` (54.40% translated) : Français (France) - French * `fr.ini` (49.19% translated) : Français (France) - French
* `ru.ini` (53.50% translated) : Русский (Russkiy) - Russian * `ru.ini` (48.38% translated) : Русский (Russkiy) - Russian
* `vi.ini` (53.50% translated) : Tiếng Việt (Việt Nam) - Vietnamese * `vi.ini` (48.38% translated) : Tiếng Việt (Việt Nam) - Vietnamese
* `zh-Hans.ini` (100.00% translated) : 简体中文 - Chinese Simplified * `zh-Hans.ini` (90.43% translated) : 简体中文 - Chinese Simplified
* `zh-Hant.ini` (100.00% translated) : 繁體中文 - Chinese Traditional * `zh-Hant.ini` (90.43% translated) : 繁體中文 - Chinese Traditional
## Building from the source 🏗️ ## Building from the source 🏗️