GH-3602 Create .minecraft before running pre-launch commands
This commit is contained in:
28
api/logic/minecraft/launch/CreateGameFolders.cpp
Normal file
28
api/logic/minecraft/launch/CreateGameFolders.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "CreateGameFolders.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
CreateGameFolders::CreateGameFolders(LaunchTask* parent): LaunchStep(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CreateGameFolders::executeTask()
|
||||
{
|
||||
auto instance = m_parent->instance();
|
||||
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
|
||||
|
||||
if(!FS::ensureFolderPathExists(minecraftInstance->gameRoot()))
|
||||
{
|
||||
emit logLine("Couldn't create the main game folder", MessageLevel::Error);
|
||||
emitFailed("Couldn't create the main game folder");
|
||||
return;
|
||||
}
|
||||
|
||||
// HACK: this is a workaround for MCL-3732 - 'server-resource-packs' folder is created.
|
||||
if(!FS::ensureFolderPathExists(FS::PathCombine(minecraftInstance->gameRoot(), "server-resource-packs")))
|
||||
{
|
||||
emit logLine("Couldn't create the 'server-resource-packs' folder", MessageLevel::Error);
|
||||
}
|
||||
emitSucceeded();
|
||||
}
|
@ -19,13 +19,13 @@
|
||||
#include <LoggedProcess.h>
|
||||
#include <minecraft/auth/AuthSession.h>
|
||||
|
||||
// HACK: this is a workaround for MCL-3732 - 'server-resource-packs' folder is created.
|
||||
class CreateServerResourcePacksFolder: public LaunchStep
|
||||
// Create the main .minecraft for the instance and any other necessary folders
|
||||
class CreateGameFolders: public LaunchStep
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CreateServerResourcePacksFolder(LaunchTask *parent);
|
||||
virtual ~CreateServerResourcePacksFolder() {};
|
||||
explicit CreateGameFolders(LaunchTask *parent);
|
||||
virtual ~CreateGameFolders() {};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const
|
@ -1,19 +0,0 @@
|
||||
#include "CreateServerResourcePacksFolder.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
CreateServerResourcePacksFolder::CreateServerResourcePacksFolder(LaunchTask* parent): LaunchStep(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CreateServerResourcePacksFolder::executeTask()
|
||||
{
|
||||
auto instance = m_parent->instance();
|
||||
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
|
||||
if(!FS::ensureFolderPathExists(FS::PathCombine(minecraftInstance->gameRoot(), "server-resource-packs")))
|
||||
{
|
||||
emit logLine(tr("Couldn't create the 'server-resource-packs' folder"), MessageLevel::Error);
|
||||
}
|
||||
emitSucceeded();
|
||||
}
|
Reference in New Issue
Block a user