public string ParseGameArguments(AuthResultBase authResult) { var mcArgumentsDic = new Dictionary <string, string> { { "${version_name}", LaunchSettings.Version }, { "${version_type}", GameProfile?.Type ?? $"\"{LaunchSettings.LauncherName}\"" }, { "${assets_root}", $"\"{AssetRoot}\"" }, { "${assets_index_name}", $"\"{VersionInfo.AssetInfo.Id}\"" }, { "${game_directory}", $"\"{GamePathHelper.GetGamePath(LaunchSettings.Version)}\"" }, { "${auth_player_name}", authResult?.SelectedProfile?.Name }, { "${auth_uuid}", authResult?.SelectedProfile?.UUID.ToString() }, { "${auth_access_token}", authResult?.AccessToken }, { "${user_properties}", authResult?.User?.Properties.ResolveUserProperties() }, { "${user_type}", "Mojang" } // use default value as placeholder }; return(StringHelper.ReplaceByDic(VersionInfo.GameArguments, mcArgumentsDic)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="launchSettings">启动设置</param> /// <param name="launcherProfileParser">Mojang官方launcher_profiles.json适配组件</param> /// <param name="versionLocator"></param> /// <param name="authResult"></param> /// <param name="rootPath"></param> /// <param name="rootVersion"></param> public DefaultLaunchArgumentParser(LaunchSettings launchSettings, ILauncherProfileParser launcherProfileParser, IVersionLocator versionLocator, AuthResultBase authResult, string rootPath, string rootVersion) { if (launchSettings == null || launcherProfileParser == null) { throw new ArgumentNullException(); } AuthResult = authResult; VersionLocator = versionLocator; RootPath = rootPath; LaunchSettings = launchSettings; LauncherProfileParser = launcherProfileParser; VersionInfo = LaunchSettings.VersionLocator.GetGame(LaunchSettings.Version); GameProfile = LauncherProfileParser.GetGameProfile(LaunchSettings.GameName); ClassPath = string.Join(string.Empty, VersionInfo.Libraries.Select(l => $"{GamePathHelper.GetLibraryPath(l.Path.Replace('/', '\\'))};")); ClassPath += string.IsNullOrEmpty(rootVersion) ? GamePathHelper.GetGameExecutablePath(launchSettings.Version) : GamePathHelper.GetGameExecutablePath(rootVersion); LastAuthResult = LaunchSettings.Authenticator.GetLastAuthResult(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="authResult">验证结果</param> public LaunchWrapper(AuthResultBase authResult) { AuthResult = authResult; }