From a56529dace03bd6d15ff96c15e5f5545018998c1 Mon Sep 17 00:00:00 2001 From: laolarou Date: Sun, 16 Jul 2023 11:30:53 +0800 Subject: [PATCH] Update QuiltInstaller.cs --- .../DefaultComponent/Installer/QuiltInstaller.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Installer/QuiltInstaller.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Installer/QuiltInstaller.cs index 16ec0da1..9b1b335d 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Installer/QuiltInstaller.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Installer/QuiltInstaller.cs @@ -20,6 +20,7 @@ public class QuiltInstaller : InstallerBase, IQuiltInstaller static HttpClient Client => HttpClientHelper.DefaultClient; public QuiltLoaderModel LoaderArtifact { get; set; } + public string? MineCraftVersion { get; set; } public string Install() { @@ -28,14 +29,14 @@ public string Install() public async Task InstallTaskAsync() { - if (string.IsNullOrEmpty(InheritsFrom)) - throw new NullReferenceException("InheritsFrom 不能为 null"); + if (string.IsNullOrEmpty(MineCraftVersion)) + throw new NullReferenceException("MineCraftVersion 不能为 null"); if (string.IsNullOrEmpty(RootPath)) throw new NullReferenceException("RootPath 不能为 null"); InvokeStatusChangedEvent("开始安装", 0); - var url = $"{DefaultMetaUrl}/v3/versions/loader/{InheritsFrom}/{LoaderArtifact.Version}/profile/json"; + var url = $"{DefaultMetaUrl}/v3/versions/loader/{MineCraftVersion}/{LoaderArtifact.Version}/profile/json"; using var req = new HttpRequestMessage(HttpMethod.Get, url); using var res = await Client.SendAsync(req); @@ -69,8 +70,10 @@ public async Task InstallTaskAsync() if (!string.IsNullOrEmpty(CustomId)) versionModel.Id = CustomId; + if(!string.IsNullOrEmpty(InheritsFrom)) + versionModel.InheritsFrom = InheritsFrom; - var id = versionModel.Id; + var id = versionModel.Id!; var installPath = Path.Combine(RootPath, GamePathHelper.GetGamePath(id)); var di = new DirectoryInfo(installPath);