Implement dependency support for Modrinth (fixes #56)

This commit is contained in:
comp500
2022-08-25 03:48:34 +01:00
parent 89f189256e
commit 503232a3fa
3 changed files with 209 additions and 41 deletions

View File

@@ -138,3 +138,22 @@ func getBestHash(v *modrinthApi.File) (string, string) {
//No hashes were present
return "", ""
}
func getInstalledProjectIDs(index *core.Index) []string {
var installedProjects []string
for _, modPath := range index.GetAllMods() {
mod, err := core.LoadMod(modPath)
if err == nil {
data, ok := mod.GetParsedUpdateData("modrinth")
if ok {
updateData, ok := data.(mrUpdateData)
if ok {
if len(updateData.ModID) > 0 {
installedProjects = append(installedProjects, updateData.ModID)
}
}
}
}
}
return installedProjects
}