add support for {ref} placeholder

This commit is contained in:
2025-04-21 20:43:09 +02:00
parent 986257c0a4
commit 96cd9bcaac
3 changed files with 17 additions and 2 deletions

View File

@@ -47,4 +47,18 @@ public static class Extensions
return @this.SourceUrl; return @this.SourceUrl;
return @this.SourceUrl.Replace("{version}", version.ToString(3)); return @this.SourceUrl.Replace("{version}", version.ToString(3));
} }
public static string GetInstallUrl(this ModpackConfig @this)
{
if (string.IsNullOrWhiteSpace(@this.RefTag))
return @this.InstallUrl;
return @this.InstallUrl.Replace("{ref}", @this.RefTag);
}
public static string GetUpdateUrl(this ModpackConfig @this)
{
if (string.IsNullOrWhiteSpace(@this.RefTag))
return @this.UpdateUrl;
return @this.UpdateUrl.Replace("{ref}", @this.RefTag);
}
} }

View File

@@ -32,13 +32,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
private async Task<UpdateInfos> DownloadUpdateInfos() private async Task<UpdateInfos> DownloadUpdateInfos()
{ {
var content = await http.GetStringAsync(updateConfig.UpdateUrl); var content = await http.GetStringAsync(updateConfig.GetUpdateUrl());
return UpdateInfos.Parse(content); return UpdateInfos.Parse(content);
} }
private async Task<InstallInfos> DownloadInstallInfos() private async Task<InstallInfos> DownloadInstallInfos()
{ {
var content = await http.GetStringAsync(updateConfig.InstallUrl); var content = await http.GetStringAsync(updateConfig.GetInstallUrl());
return InstallInfos.Parse(content); return InstallInfos.Parse(content);
} }

View File

@@ -13,6 +13,7 @@ public class ModpackConfig
public string UnleashInstanceId { get; set; } public string UnleashInstanceId { get; set; }
public bool PreferDirectLinks { get; set; } public bool PreferDirectLinks { get; set; }
public string MinecraftVersion { get; set; } public string MinecraftVersion { get; set; }
public string RefTag { get; set; }
[JsonConverter(typeof(StringEnumConverter))] [JsonConverter(typeof(StringEnumConverter))]
public ModLoader ModLoader { get; set; } public ModLoader ModLoader { get; set; }