MCPcopy Create free account
hub / github.com/MultiMC/Launcher / plusJarModFromJson

Method plusJarModFromJson

launcher/minecraft/OneSixVersionFormat.cpp:332–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332LibraryPtr 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
372LibraryPtr OneSixVersionFormat::jarModFromJson(ProblemContainer & problems, const QJsonObject& libObj, const QString& filename)
373{

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