@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
#include "ModMinecraftJar.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include "MMCZip.h"
|
||||
#include "FileSystem.h"
|
||||
#include "MMCZip.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
|
||||
@ -44,20 +44,17 @@ void ModMinecraftJar::executeTask()
|
||||
{
|
||||
auto m_inst = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
|
||||
|
||||
if(!m_inst->getJarMods().size())
|
||||
{
|
||||
if (!m_inst->getJarMods().size()) {
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
// nuke obsolete stripped jar(s) if needed
|
||||
if(!FS::ensureFolderPathExists(m_inst->binRoot()))
|
||||
{
|
||||
if (!FS::ensureFolderPathExists(m_inst->binRoot())) {
|
||||
emitFailed(tr("Couldn't create the bin folder for Minecraft.jar"));
|
||||
}
|
||||
|
||||
auto finalJarPath = QDir(m_inst->binRoot()).absoluteFilePath("minecraft.jar");
|
||||
if(!removeJar())
|
||||
{
|
||||
if (!removeJar()) {
|
||||
emitFailed(tr("Couldn't remove stale jar file: %1").arg(finalJarPath));
|
||||
}
|
||||
|
||||
@ -65,14 +62,12 @@ void ModMinecraftJar::executeTask()
|
||||
auto components = m_inst->getPackProfile();
|
||||
auto profile = components->getProfile();
|
||||
auto jarMods = m_inst->getJarMods();
|
||||
if(jarMods.size())
|
||||
{
|
||||
if (jarMods.size()) {
|
||||
auto mainJar = profile->getMainJar();
|
||||
QStringList jars, temp1, temp2, temp3, temp4;
|
||||
mainJar->getApplicableFiles(m_inst->runtimeContext(), jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath());
|
||||
auto sourceJarPath = jars[0];
|
||||
if(!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods))
|
||||
{
|
||||
if (!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods)) {
|
||||
emitFailed(tr("Failed to create the custom Minecraft jar file."));
|
||||
return;
|
||||
}
|
||||
@ -90,10 +85,8 @@ bool ModMinecraftJar::removeJar()
|
||||
auto m_inst = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
|
||||
auto finalJarPath = QDir(m_inst->binRoot()).absoluteFilePath("minecraft.jar");
|
||||
QFile finalJar(finalJarPath);
|
||||
if(finalJar.exists())
|
||||
{
|
||||
if(!finalJar.remove())
|
||||
{
|
||||
if (finalJar.exists()) {
|
||||
if (!finalJar.remove()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user