| 22 | #include "minecraft/PackProfile.h" |
| 23 | |
| 24 | void ModMinecraftJar::executeTask() |
| 25 | { |
| 26 | auto m_inst = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance()); |
| 27 | |
| 28 | if(!m_inst->getJarMods().size()) |
| 29 | { |
| 30 | emitSucceeded(); |
| 31 | return; |
| 32 | } |
| 33 | // nuke obsolete stripped jar(s) if needed |
| 34 | if(!FS::ensureFolderPathExists(m_inst->binRoot())) |
| 35 | { |
| 36 | emitFailed(tr("Couldn't create the bin folder for Minecraft.jar")); |
| 37 | } |
| 38 | |
| 39 | auto finalJarPath = QDir(m_inst->binRoot()).absoluteFilePath("minecraft.jar"); |
| 40 | if(!removeJar()) |
| 41 | { |
| 42 | emitFailed(tr("Couldn't remove stale jar file: %1").arg(finalJarPath)); |
| 43 | } |
| 44 | |
| 45 | // create temporary modded jar, if needed |
| 46 | auto components = m_inst->getPackProfile(); |
| 47 | auto profile = components->getProfile(); |
| 48 | auto jarMods = m_inst->getJarMods(); |
| 49 | if(jarMods.size()) |
| 50 | { |
| 51 | auto mainJar = profile->getMainJar(); |
| 52 | QStringList jars, temp1, temp2, temp3, temp4; |
| 53 | mainJar->getApplicableFiles(currentSystem, jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath()); |
| 54 | auto sourceJarPath = jars[0]; |
| 55 | if(!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods)) |
| 56 | { |
| 57 | emitFailed(tr("Failed to create the custom Minecraft jar file.")); |
| 58 | return; |
| 59 | } |
| 60 | } |
| 61 | emitSucceeded(); |
| 62 | } |
| 63 | |
| 64 | void ModMinecraftJar::finalize() |
| 65 | { |
nothing calls this directly
no test coverage detected