prioritize fabric/quilt.mod.json

This commit is contained in:
Merith-TK 2023-05-06 10:53:54 -07:00
parent f8a0e267b0
commit 5c2cfc7275

17
main.go
View file

@ -56,6 +56,12 @@ func main() {
// for modjars, // for modjars,
for _, file := range files { for _, file := range files {
// filter out non-jars
if !strings.HasSuffix(file.Name(), ".jar") {
log.Println("[SKIP]", file.Name())
continue
}
// read the mod.json file and return the name, version, and filename // read the mod.json file and return the name, version, and filename
name, version, loader := readMod("./mods/" + file.Name()) name, version, loader := readMod("./mods/" + file.Name())
name = cleanPattern.ReplaceAllString(name, "") name = cleanPattern.ReplaceAllString(name, "")
@ -136,7 +142,9 @@ func readMod(filename string) (string, string, string) {
log.Println("[DECODE ERROR]", filename) log.Println("[DECODE ERROR]", filename)
log.Fatalln("[DECODE FORGE MOD]", forgeTomlErr) log.Fatalln("[DECODE FORGE MOD]", forgeTomlErr)
} }
break // NOTICE: We don't break here because we want to check if there is a fabric/quilt mod.json,
// if there is, then we will use that instead of the forge mod.toml due to inconsistencies
// between the forge mod.tomls
} }
} }
@ -149,8 +157,11 @@ func readMod(filename string) (string, string, string) {
return quiltJson.QuiltLoader.Metadata.Name, quiltJson.QuiltLoader.Version, loader return quiltJson.QuiltLoader.Metadata.Name, quiltJson.QuiltLoader.Version, loader
} }
if loader == "forge" { if loader == "forge" {
forgeMods = append(forgeMods, forgeMod) if len(forgeMod.Mods) != 0 {
return forgeMod.Mods[0].DisplayName, forgeMod.Mods[0].Version, loader forgeMods = append(forgeMods, forgeMod)
log.Println("Forge Mod", filename)
return forgeMod.Mods[0].DisplayName, forgeMod.Mods[0].Version, loader
}
} }
return "", "", "" return "", "", ""
} }