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

Method detectLibrary

launcher/modplatform/atlauncher/ATLPackInstallTask.cpp:396–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396QString PackInstallTask::detectLibrary(VersionLibrary library)
397{
398 // Try to detect what the library is
399 if (!library.server.isEmpty() && library.server.split("/").length() >= 3) {
400 auto lastSlash = library.server.lastIndexOf("/");
401 auto locationAndVersion = library.server.mid(0, lastSlash);
402 auto fileName = library.server.mid(lastSlash + 1);
403
404 lastSlash = locationAndVersion.lastIndexOf("/");
405 auto location = locationAndVersion.mid(0, lastSlash);
406 auto version = locationAndVersion.mid(lastSlash + 1);
407
408 lastSlash = location.lastIndexOf("/");
409 auto group = location.mid(0, lastSlash).replace("/", ".");
410 auto artefact = location.mid(lastSlash + 1);
411
412 return group + ":" + artefact + ":" + version;
413 }
414
415 if(library.file.contains("-")) {
416 auto lastSlash = library.file.lastIndexOf("-");
417 auto name = library.file.mid(0, lastSlash);
418 auto version = library.file.mid(lastSlash + 1).remove(".jar");
419
420 if(name == QString("guava")) {
421 return "com.google.guava:guava:" + version;
422 }
423 else if(name == QString("commons-lang3")) {
424 return "org.apache.commons:commons-lang3:" + version;
425 }
426 }
427
428 return "org.multimc.atlauncher:" + library.md5 + ":1";
429}
430
431bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
432{

Callers

nothing calls this directly

Calls 6

QStringClass · 0.85
isEmptyMethod · 0.80
lengthMethod · 0.80
replaceMethod · 0.45
containsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected