https://github.com/QuiltMC/rfcs/blob/master/specification/0002-quilt.mod.json.md
| 205 | |
| 206 | // https://github.com/QuiltMC/rfcs/blob/master/specification/0002-quilt.mod.json.md |
| 207 | ModDetails ReadQuiltModInfo(QByteArray contents) |
| 208 | { |
| 209 | QJsonParseError jsonError; |
| 210 | QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError); |
| 211 | auto object = Json::requireObject(jsonDoc, "quilt.mod.json"); |
| 212 | auto schemaVersion = Json::ensureInteger(object.value("schema_version"), 0, "Quilt schema_version"); |
| 213 | |
| 214 | ModDetails details; |
| 215 | |
| 216 | // https://github.com/QuiltMC/rfcs/blob/be6ba280d785395fefa90a43db48e5bfc1d15eb4/specification/0002-quilt.mod.json.md |
| 217 | if (schemaVersion == 1) { |
| 218 | auto modInfo = Json::requireObject(object.value("quilt_loader"), "Quilt mod info"); |
| 219 | |
| 220 | details.mod_id = Json::requireString(modInfo.value("id"), "Mod ID"); |
| 221 | details.version = Json::requireString(modInfo.value("version"), "Mod version"); |
| 222 | |
| 223 | auto modMetadata = Json::ensureObject(modInfo.value("metadata")); |
| 224 | |
| 225 | details.name = Json::ensureString(modMetadata.value("name"), details.mod_id); |
| 226 | details.description = Json::ensureString(modMetadata.value("description")); |
| 227 | |
| 228 | auto modContributors = Json::ensureObject(modMetadata.value("contributors")); |
| 229 | |
| 230 | // We don't really care about the role of a contributor here |
| 231 | details.authors += modContributors.keys(); |
| 232 | |
| 233 | auto modContact = Json::ensureObject(modMetadata.value("contact")); |
| 234 | |
| 235 | if (modContact.contains("homepage")) { |
| 236 | details.homeurl = Json::requireString(modContact.value("homepage")); |
| 237 | } |
| 238 | } |
| 239 | return details; |
| 240 | } |
| 241 | |
| 242 | ModDetails ReadForgeInfo(QByteArray contents) |
| 243 | { |
no test coverage detected