TheRandomLabs / CurseAPI-Minecraft

An extension of CurseAPI for parsing CurseForge modpack manifests and for performing more Minecraft-specific operations.
MIT License
7 stars 1 forks source link

Parsed CurseModpack JSON files list empty #7

Closed ViRb3 closed 4 years ago

ViRb3 commented 4 years ago

Hello, I am trying to parse a CurseModpack JSON (minecraftinstance.json from Twitch App), and while the rest of the data loads, the files list remains empty. There are no errors in the log. I tried with some of the major modpacks out there, including a simple, one-mod test file attached below. Here is my code (Kotlin, the syntax is almost identical to Java):

fun main() {
    BasicConfigurator.configure()
    CurseAPIMinecraft.initialize()
    val modpack = CurseModpack.fromJSON(Paths.get("minecraftinstance.json"))
    print(modpack.files())
}

minecraftinstance.zip

TheRandomLabs commented 4 years ago

Oh dear, it looks like they've updated the manifest format. I'll fix this tomorrow if I can.

ViRb3 commented 4 years ago

Could you please give me a starting direction on how to debug JSON parsing with Moshi? I would've hoped it would throw an error instead of skipping deserialization. I'm more than happy to submit a PR.

TheRandomLabs commented 4 years ago

Don't worry about the PR; I've already got a good idea of how I want to implement this. :) You're right that it should have thrown an error. Deserialization wasn't skipped; it was just assumed that the modpack was empty because the default values were used, since the old properties weren't found.

ViRb3 commented 4 years ago

Ah, that makes sense. I can see the problem now as well. Looking forward to your update!

TheRandomLabs commented 4 years ago

Sorry, I got the wrong idea last night. The manifest format has not been updated; you're trying to parse a minecraftinstance.json rather than a manifest.json. However, I didn't realize this until it was too late, so see if you can make use of what I've written so far. It implements CurseModpack, but it isn't in a very polished state. Look at CurseModpack#fromJSON to see how to parse it. :P