fix deduping mods
This commit is contained in:
parent
6e70bee955
commit
243e173787
2 changed files with 79 additions and 4 deletions
19
main.go
19
main.go
|
@ -44,12 +44,14 @@ func main() {
|
|||
// read the mod.json file and return the name, version, and filename
|
||||
name, version, loader := readMod("./mods/" + file.Name())
|
||||
if loader != "" {
|
||||
// rename the file to Name-Version.jar
|
||||
// remove invalid path characters from the name using regex
|
||||
// name = regexp.MustCompile(`[^\w\-. ]`).ReplaceAllString(name, "")
|
||||
err := os.Rename("./mods/"+file.Name(), "./mods/"+name+"-"+version+".jar")
|
||||
if err != nil {
|
||||
log.Fatalln("[RENAME MOD]", err)
|
||||
} else {
|
||||
log.Println("[RENAME MOD]", file.Name(), ">>", name+"-"+version+".jar")
|
||||
}
|
||||
log.Println(loader, name, version)
|
||||
} else {
|
||||
log.Println("Unsupported Loader", file.Name())
|
||||
}
|
||||
|
@ -87,11 +89,20 @@ func readMod(filename string) (string, string, string) {
|
|||
if file.Name == "fabric.mod.json" {
|
||||
loader = "fabric"
|
||||
// add to fabric list
|
||||
json.NewDecoder(contents).Decode(&fabricJson)
|
||||
fabricJsonErr := json.NewDecoder(contents).Decode(&fabricJson)
|
||||
if fabricJsonErr != nil {
|
||||
log.Println("[DECODE ERROR]", filename)
|
||||
log.Fatalln("[DECODE FABRIC MOD]", fabricJsonErr)
|
||||
}
|
||||
}
|
||||
if file.Name == "quilt.mod.json" {
|
||||
loader = "quilt"
|
||||
json.NewDecoder(contents).Decode(&quiltJson)
|
||||
quiltJsonErr := json.NewDecoder(contents).Decode(&quiltJson)
|
||||
if quiltJsonErr != nil {
|
||||
log.Println(filename)
|
||||
log.Println("[DECODE ERROR]", filename)
|
||||
log.Fatalln("[DECODE QUILT MOD]", quiltJsonErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
64
quilt.mod.json
Normal file
64
quilt.mod.json
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"schema_version": 1,
|
||||
"quilt_loader": {
|
||||
"group": "eu.midnightdust",
|
||||
"id": "midnightlib",
|
||||
"version": "1.3.0",
|
||||
"intermediate_mappings": "net.fabricmc:intermediary",
|
||||
"entrypoints": {
|
||||
"client_init": [
|
||||
"eu.midnightdust.quilt.core.MidnightLibClientQuilt"
|
||||
],
|
||||
"server_init": [
|
||||
"eu.midnightdust.quilt.core.MidnightLibServerQuilt"
|
||||
],
|
||||
"modmenu": [
|
||||
"eu.midnightdust.lib.config.AutoModMenu"
|
||||
]
|
||||
},
|
||||
"depends": [
|
||||
{
|
||||
"id": "quilt_loader",
|
||||
"version": "*"
|
||||
},
|
||||
{
|
||||
"id": "quilt_base",
|
||||
"version": "*"
|
||||
},
|
||||
{
|
||||
"id": "minecraft",
|
||||
"version": ">=1.19.4"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"name": "MidnightLib (Patched)",
|
||||
"description": "Common Library for Team MidnightDust's mods. \nProvides a config api, automatic integration with other mods, common utils, and cosmetics.",
|
||||
"license": "MIT",
|
||||
"environment": "*",
|
||||
"contributors": {
|
||||
"Motschen": "Author",
|
||||
"TeamMidnightDust": "Mascot"
|
||||
},
|
||||
"contact": {
|
||||
"email": "mail@midnightdust.eu",
|
||||
"homepage": "https://modrinth.com/mod/midnightlib",
|
||||
"issues": "https://github.com/TeamMidnightDust/MidnightLib/issues",
|
||||
"sources": "https://github.com/TeamMidnightDust/MidnightLib"
|
||||
},
|
||||
"icon": "assets/midnightlib/icon.png"
|
||||
}
|
||||
},
|
||||
"mixin": [
|
||||
"midnightlib.mixins.json"
|
||||
],
|
||||
"modmenu": {
|
||||
"links": {
|
||||
"modmenu.discord": "https://discord.midnightdust.eu/",
|
||||
"modmenu.website": "https://www.midnightdust.eu/",
|
||||
"midnightlib.curseforge": "https://www.curseforge.com/minecraft/mc-mods/midnightlib",
|
||||
"midnightlib.modrinth": "https://modrinth.com/mod/midnightlib",
|
||||
"midnightlib.wiki": "https://github.com/TeamMidnightDust/MidnightLib/wiki"
|
||||
},
|
||||
"badges": [ "library" ]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue