| 330 | } |
| 331 | |
| 332 | LibraryPtr OneSixVersionFormat::plusJarModFromJson( |
| 333 | ProblemContainer & problems, |
| 334 | const QJsonObject &libObj, |
| 335 | const QString &filename, |
| 336 | const QString &originalName |
| 337 | ) { |
| 338 | LibraryPtr out(new Library()); |
| 339 | if (!libObj.contains("name")) |
| 340 | { |
| 341 | throw JSONValidationError(filename + |
| 342 | "contains a jarmod that doesn't have a 'name' field"); |
| 343 | } |
| 344 | |
| 345 | // just make up something unique on the spot for the library name. |
| 346 | auto uuid = QUuid::createUuid(); |
| 347 | QString id = uuid.toString().remove('{').remove('}'); |
| 348 | out->setRawName(GradleSpecifier("org.multimc.jarmods:" + id + ":1")); |
| 349 | |
| 350 | // filename override is the old name |
| 351 | out->setFilename(libObj.value("name").toString()); |
| 352 | |
| 353 | // it needs to be local, it is stored in the instance jarmods folder |
| 354 | out->setHint("local"); |
| 355 | |
| 356 | // read the original name if present - some versions did not set it |
| 357 | // it is the original jar mod filename before it got renamed at the point of addition |
| 358 | auto displayName = libObj.value("originalName").toString(); |
| 359 | if(displayName.isEmpty()) |
| 360 | { |
| 361 | auto fixed = originalName; |
| 362 | fixed.remove(" (jar mod)"); |
| 363 | out->setDisplayName(fixed); |
| 364 | } |
| 365 | else |
| 366 | { |
| 367 | out->setDisplayName(displayName); |
| 368 | } |
| 369 | return out; |
| 370 | } |
| 371 | |
| 372 | LibraryPtr OneSixVersionFormat::jarModFromJson(ProblemContainer & problems, const QJsonObject& libObj, const QString& filename) |
| 373 | { |
nothing calls this directly
no test coverage detected