From 5c2cfc7275c2ac020b9e054454f1e24be779fdac Mon Sep 17 00:00:00 2001 From: Merith-TK Date: Sat, 6 May 2023 10:53:54 -0700 Subject: [PATCH] prioritize fabric/quilt.mod.json --- main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 540d371..65504f4 100644 --- a/main.go +++ b/main.go @@ -56,6 +56,12 @@ func main() { // for modjars, 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 name, version, loader := readMod("./mods/" + file.Name()) name = cleanPattern.ReplaceAllString(name, "") @@ -136,7 +142,9 @@ func readMod(filename string) (string, string, string) { log.Println("[DECODE ERROR]", filename) 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 } if loader == "forge" { - forgeMods = append(forgeMods, forgeMod) - return forgeMod.Mods[0].DisplayName, forgeMod.Mods[0].Version, loader + if len(forgeMod.Mods) != 0 { + forgeMods = append(forgeMods, forgeMod) + log.Println("Forge Mod", filename) + return forgeMod.Mods[0].DisplayName, forgeMod.Mods[0].Version, loader + } } return "", "", "" }