update
This commit is contained in:
@@ -56,36 +56,37 @@ public class ModpackFactory
|
||||
return action.GetSourceUrl(targetVersion, overwriteVersion: overwriteVersion);
|
||||
}
|
||||
|
||||
public async Task<KeyValuePair<string, string>[]> FindUpdates(InstallAction action, string? gameVersion, ModLoader modLoader)
|
||||
public async Task<KeyValuePair<string, string>[]?> FindUpdates(InstallAction action, string? gameVersion, ModLoader modLoader)
|
||||
{
|
||||
if (action.SourceType == SourceType.GitHub)
|
||||
switch (action.SourceType)
|
||||
{
|
||||
try
|
||||
case SourceType.GitHub:
|
||||
try
|
||||
{
|
||||
var repo = await github.Repository.Get(action.SourceOwner, action.SourceName);
|
||||
var releases = await github.Repository.Release.GetAll(repo.Id);
|
||||
return releases.Select(r => new KeyValuePair<string, string>(r.TagName, r.Name ?? r.TagName)).ToArray();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
break;
|
||||
case SourceType.GitLab:
|
||||
throw new NotImplementedException("To be implemented soon.");
|
||||
case SourceType.CurseForge:
|
||||
{
|
||||
var repo = await github.Repository.Get(action.SourceOwner, action.SourceName);
|
||||
var releases = await github.Repository.Release.GetAll(repo.Id);
|
||||
return releases.Select(r => new KeyValuePair<string, string>(r.Name ?? r.TagName, r.TagName)).ToArray();
|
||||
var res = await curseForge.GetModFilesAsync(Convert.ToInt32(action.SourceName), gameVersion: gameVersion, modLoaderType: GetModLoaderForCurseForge(modLoader));
|
||||
if (res.Data != null)
|
||||
return res.Data.Select(n => new KeyValuePair<string, string>(n.DisplayName, n.Id.ToString())).ToArray();
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
case SourceType.Modrinth:
|
||||
{
|
||||
var res = await modrinth.Version.GetProjectVersionListAsync(action.SourceName, gameVersions: GetGameVersionForModrinth(gameVersion), loaders: GetModLoaderForModrinth(modLoader));
|
||||
return res.Select(v => new KeyValuePair<string, string>($"{v.VersionNumber} {v.ProjectVersionType} {v.Name}", v.Id)).ToArray();
|
||||
}
|
||||
}
|
||||
else if (action.SourceType == SourceType.GitLab)
|
||||
{
|
||||
throw new NotImplementedException("To be implemented soon.");
|
||||
}
|
||||
else if (action.SourceType == SourceType.CurseForge)
|
||||
{
|
||||
var res = await curseForge.GetModFilesAsync(Convert.ToInt32(action.SourceName), gameVersion: gameVersion, modLoaderType: GetModLoaderForCurseForge(modLoader));
|
||||
if (res.Data != null)
|
||||
return res.Data.Select(n => new KeyValuePair<string, string>(n.DisplayName, n.Id.ToString())).ToArray();
|
||||
}
|
||||
else if (action.SourceType == SourceType.Modrinth)
|
||||
{
|
||||
var res = await modrinth.Version.GetProjectVersionListAsync(action.SourceName, gameVersions: GetGameVersionForModrinth(gameVersion), loaders: GetModLoaderForModrinth(modLoader));
|
||||
return res.Select(v => new KeyValuePair<string, string>($"{v.VersionNumber} {v.ProjectVersionType} {v.Name}", v.Id)).ToArray();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user