AddYggdrasilLogin

This commit is contained in:
Polaris_Light 2023-11-12 21:04:20 +08:00
parent eb8ccc43d7
commit 3c97193b70
6 changed files with 156 additions and 25 deletions

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MinecraftClient.Scripting;
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig;
namespace MinecraftClient.Protocol.Session
{
@ -32,13 +33,15 @@ namespace MinecraftClient.Protocol.Session
ServerPublicKey = null;
}
public bool SessionPreCheck()
public bool SessionPreCheck(LoginType type)
{
if (ID == string.Empty || PlayerID == String.Empty || ServerPublicKey == null)
return false;
Crypto.CryptoHandler.ClientAESPrivateKey ??= Crypto.CryptoHandler.GenerateAESPrivateKey();
string serverHash = Crypto.CryptoHandler.GetServerHash(ServerIDhash, ServerPublicKey, Crypto.CryptoHandler.ClientAESPrivateKey);
if (ProtocolHandler.SessionCheck(PlayerID, ID, serverHash))
if (type == LoginType.mojang && ProtocolHandler.SessionCheck(PlayerID, ID, serverHash))
return true;
if (type == LoginType.Yggdrasil && ProtocolHandler.YggdrasilSessionCheck(PlayerID, ID, serverHash))
return true;
return false;
}