MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / plusJarModFromJson

Method plusJarModFromJson

launcher/minecraft/OneSixVersionFormat.cpp:391–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391LibraryPtr OneSixVersionFormat::plusJarModFromJson(
392 ProblemContainer & problems,
393 const QJsonObject &libObj,
394 const QString &filename,
395 const QString &originalName
396) {
397 LibraryPtr out(new Library());
398 if (!libObj.contains("name"))
399 {
400 throw JSONValidationError(filename +
401 "contains a jarmod that doesn't have a 'name' field");
402 }
403
404 // just make up something unique on the spot for the library name.
405 auto uuid = QUuid::createUuid();
406 QString id = uuid.toString().remove('{').remove('}');
407 out->setRawName(GradleSpecifier("org.multimc.jarmods:" + id + ":1"));
408
409 // filename override is the old name
410 out->setFilename(libObj.value("name").toString());
411
412 // it needs to be local, it is stored in the instance jarmods folder
413 out->setHint("local");
414
415 // read the original name if present - some versions did not set it
416 // it is the original jar mod filename before it got renamed at the point of addition
417 auto displayName = libObj.value("originalName").toString();
418 if(displayName.isEmpty())
419 {
420 auto fixed = originalName;
421 fixed.remove(" (jar mod)");
422 out->setDisplayName(fixed);
423 }
424 else
425 {
426 out->setDisplayName(displayName);
427 }
428 return out;
429}
430
431LibraryPtr OneSixVersionFormat::jarModFromJson(ProblemContainer & problems, const QJsonObject& libObj, const QString& filename)
432{

Callers

nothing calls this directly

Calls 9

GradleSpecifierClass · 0.85
setRawNameMethod · 0.80
setFilenameMethod · 0.80
setHintMethod · 0.80
isEmptyMethod · 0.80
setDisplayNameMethod · 0.80
containsMethod · 0.45
removeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected