mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Startup Optimization
This commit is contained in:
parent
3d13eb51e6
commit
c90ea0e92b
6 changed files with 104 additions and 70 deletions
|
|
@ -52,7 +52,7 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
new Thread(() =>
|
||||
{
|
||||
//Take advantage of Windows 10 / Mac / Linux UTF-8 console
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
|
|
@ -69,7 +69,10 @@ namespace MinecraftClient
|
|||
|
||||
// Fix issue #2119
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
});
|
||||
|
||||
// "ToLower" require "CultureInfo" to be initialized on first run, which can take a lot of time.
|
||||
// _ = "a".ToLower();
|
||||
}).Start();
|
||||
|
||||
//Setup ConsoleIO
|
||||
ConsoleIO.LogPrefix = "§8[MCC] ";
|
||||
|
|
@ -102,7 +105,7 @@ namespace MinecraftClient
|
|||
}
|
||||
|
||||
//Process ini configuration file
|
||||
if (args.Length >= 1 && System.IO.File.Exists(args[0]) && System.IO.Path.GetExtension(args[0]).ToLower() == ".ini")
|
||||
if (args.Length >= 1 && System.IO.File.Exists(args[0]) && Settings.ToLowerIfNeed(Path.GetExtension(args[0])) == ".ini")
|
||||
{
|
||||
Settings.LoadFile(args[0]);
|
||||
|
||||
|
|
@ -163,7 +166,7 @@ namespace MinecraftClient
|
|||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(dataGenerator) || !(dataGenerator.ToLower().Equals("entity") || dataGenerator.ToLower().Equals("item") || dataGenerator.ToLower().Equals("block")))
|
||||
if (string.IsNullOrEmpty(dataGenerator) || !(Settings.ToLowerIfNeed(dataGenerator).Equals("entity") || Settings.ToLowerIfNeed(dataGenerator).Equals("item") || Settings.ToLowerIfNeed(dataGenerator).Equals("block")))
|
||||
{
|
||||
Console.WriteLine(Translations.Get("error.generator.invalid"));
|
||||
Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --data-generator=<entity|item|block> --data-path=\"<path to resources.json>\"");
|
||||
|
|
@ -250,7 +253,7 @@ namespace MinecraftClient
|
|||
Settings.Login = ConsoleIO.ReadLine();
|
||||
}
|
||||
if (Settings.Password == ""
|
||||
&& (Settings.SessionCaching == CacheType.None || !SessionCache.Contains(Settings.Login.ToLower()))
|
||||
&& (Settings.SessionCaching == CacheType.None || !SessionCache.Contains(Settings.ToLowerIfNeed(Settings.Login)))
|
||||
&& !useBrowser)
|
||||
{
|
||||
RequestPassword();
|
||||
|
|
@ -291,6 +294,7 @@ namespace MinecraftClient
|
|||
|
||||
ProtocolHandler.LoginResult result = ProtocolHandler.LoginResult.LoginRequired;
|
||||
|
||||
string loginLower = Settings.ToLowerIfNeed(Settings.Login);
|
||||
if (Settings.Password == "-")
|
||||
{
|
||||
Translations.WriteLineFormatted("mcc.offline");
|
||||
|
|
@ -301,9 +305,9 @@ namespace MinecraftClient
|
|||
else
|
||||
{
|
||||
// Validate cached session or login new session.
|
||||
if (Settings.SessionCaching != CacheType.None && SessionCache.Contains(Settings.Login.ToLower()))
|
||||
if (Settings.SessionCaching != CacheType.None && SessionCache.Contains(loginLower))
|
||||
{
|
||||
session = SessionCache.Get(Settings.Login.ToLower());
|
||||
session = SessionCache.Get(loginLower);
|
||||
result = ProtocolHandler.GetTokenValidation(session);
|
||||
if (result != ProtocolHandler.LoginResult.Success)
|
||||
{
|
||||
|
|
@ -338,7 +342,7 @@ namespace MinecraftClient
|
|||
}
|
||||
|
||||
if (result == ProtocolHandler.LoginResult.Success && Settings.SessionCaching != CacheType.None)
|
||||
SessionCache.Store(Settings.Login.ToLower(), session);
|
||||
SessionCache.Store(loginLower, session);
|
||||
|
||||
if (result == ProtocolHandler.LoginResult.Success)
|
||||
session.SessionPreCheckTask = Task.Factory.StartNew(() => session.SessionPreCheck());
|
||||
|
|
@ -355,9 +359,9 @@ namespace MinecraftClient
|
|||
Translations.WriteLineFormatted(cacheKeyLoaded ? "debug.keys_cache_ok" : "debug.keys_cache_fail");
|
||||
}
|
||||
|
||||
if (Settings.ProfileKeyCaching != CacheType.None && KeysCache.Contains(Settings.Login.ToLower()))
|
||||
if (Settings.ProfileKeyCaching != CacheType.None && KeysCache.Contains(loginLower))
|
||||
{
|
||||
playerKeyPair = KeysCache.Get(Settings.Login.ToLower());
|
||||
playerKeyPair = KeysCache.Get(loginLower);
|
||||
if (playerKeyPair.NeedRefresh())
|
||||
Translations.WriteLineFormatted("mcc.profile_key_invalid");
|
||||
else
|
||||
|
|
@ -370,7 +374,7 @@ namespace MinecraftClient
|
|||
playerKeyPair = KeyUtils.GetNewProfileKeys(session.ID);
|
||||
if (Settings.ProfileKeyCaching != CacheType.None && playerKeyPair != null)
|
||||
{
|
||||
KeysCache.Store(Settings.Login.ToLower(), playerKeyPair);
|
||||
KeysCache.Store(loginLower, playerKeyPair);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -442,7 +446,7 @@ namespace MinecraftClient
|
|||
int protocolversion = 0;
|
||||
ForgeInfo? forgeInfo = null;
|
||||
|
||||
if (Settings.ServerVersion != "" && Settings.ServerVersion.ToLower() != "auto")
|
||||
if (Settings.ServerVersion != "" && Settings.ToLowerIfNeed(Settings.ServerVersion) != "auto")
|
||||
{
|
||||
protocolversion = Protocol.ProtocolHandler.MCVer2ProtocolVersion(Settings.ServerVersion);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue