some fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Modrinth;
|
||||
using CurseForge.APIClient.Models.Mods;
|
||||
using Modrinth;
|
||||
using Octokit;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -6,8 +7,11 @@ namespace ModpackUpdater.Manager;
|
||||
|
||||
public class ModpackFactory
|
||||
{
|
||||
private readonly GitHubClient github = new(new ProductHeaderValue("MinecraftModpackUpdater"));
|
||||
private readonly CurseForge.APIClient.ApiClient curseForge = new("$2a$10$pE4dD09gmr7IcOe8hjWhleWWjXopJcDNpq1P9FlrDMCBw05pCyAXa", "pilzinsel64@gmx.de"); // b67bd218-e011-4963-ac8a-ffd025e1091f
|
||||
private readonly GitHubClient github = new(new ProductHeaderValue("MinecraftModpackUpdater"))
|
||||
{
|
||||
Credentials = new Credentials("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"),
|
||||
};
|
||||
private readonly CurseForge.APIClient.ApiClient curseForge = new("$2a$10$pE4dD09gmr7IcOe8hjWhleWWjXopJcDNpq1P9FlrDMCBw05pCyAXa", "pilzinsel64@gmx.de");
|
||||
private readonly ModrinthClient modrinth = new(new ModrinthClientConfig
|
||||
{
|
||||
ModrinthToken = "mrp_zUlDSET5actMUdTU3FK242TXgvlWgaErSSEFuegNG7thLgkC50IiK2NCGOzW",
|
||||
@@ -56,10 +60,15 @@ public class ModpackFactory
|
||||
{
|
||||
if (action.SourceType == SourceType.GitHub)
|
||||
{
|
||||
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)).ToArray();
|
||||
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.Name ?? r.TagName, r.TagName)).ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (action.SourceType == SourceType.GitLab)
|
||||
{
|
||||
@@ -67,7 +76,7 @@ public class ModpackFactory
|
||||
}
|
||||
else if (action.SourceType == SourceType.CurseForge)
|
||||
{
|
||||
var res = await curseForge.GetModFilesAsync(Convert.ToInt32(action.SourceName), gameVersion: "1.7.10", modLoaderType: CurseForge.APIClient.Models.Mods.ModLoaderType.Forge);
|
||||
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();
|
||||
}
|
||||
@@ -79,4 +88,19 @@ public class ModpackFactory
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ModLoaderType? GetModLoaderForCurseForge(ModLoader modLoader)
|
||||
{
|
||||
return modLoader switch
|
||||
{
|
||||
ModLoader.Any => null,
|
||||
ModLoader.Forge => ModLoaderType.Forge,
|
||||
ModLoader.NeoForge => ModLoaderType.NeoForge,
|
||||
ModLoader.Fabric => ModLoaderType.Fabric,
|
||||
ModLoader.LiteLoader => ModLoaderType.LiteLoader,
|
||||
ModLoader.Cauldron => ModLoaderType.Cauldron,
|
||||
ModLoader.Quilt => ModLoaderType.Quilt,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user