From c7256744c666b2a2962880e0098ab0f5e3e57627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 9 Jun 2022 23:46:28 +0200 Subject: [PATCH 1/2] GH-3012 add --offline and --name arguments These allow launching offline with a specified name from the command line. --- launcher/Application.cpp | 78 ++++++++++++++++++++++++++++------- launcher/Application.h | 5 ++- launcher/LaunchController.cpp | 47 ++++++++++++--------- launcher/LaunchController.h | 5 +++ 4 files changed, 99 insertions(+), 36 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index b0e029ad..dc3b9a75 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -247,6 +247,14 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) parser.addOption("profile"); parser.addShortOpt("profile", 'a'); parser.addDocumentation("profile", "Use the account specified by its profile name (only valid in combination with --launch)"); + // --offline + parser.addSwitch("offline"); + parser.addShortOpt("offline", 'o'); + parser.addDocumentation("offline", "Launch offline (only valid in combination with --launch)"); + // --name + parser.addOption("name"); + parser.addShortOpt("name", 'n'); + parser.addDocumentation("name", "When launching offline, use specified name (only makes sense in combination with --launch and --offline)"); // --alive parser.addSwitch("alive"); parser.addDocumentation("alive", "Write a small '" + liveCheckFile + "' file after the launcher starts"); @@ -290,6 +298,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_instanceIdToLaunch = args["launch"].toString(); m_serverToJoin = args["server"].toString(); m_profileToUse = args["profile"].toString(); + if(args["offline"].toBool()) { + m_offline = true; + m_offlineName = args["name"].toString(); + } m_liveCheck = args["alive"].toBool(); m_zipToImport = args["import"].toUrl(); @@ -355,18 +367,44 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) return; } - if(m_instanceIdToLaunch.isEmpty() && !m_serverToJoin.isEmpty()) - { - std::cerr << "--server can only be used in combination with --launch!" << std::endl; - m_status = Application::Failed; - return; - } + // all the things invalid when NOT trying to --launch + if(m_instanceIdToLaunch.isEmpty()) { + if(!m_serverToJoin.isEmpty()) + { + std::cerr << "--server can only be used in combination with --launch!" << std::endl; + m_status = Application::Failed; + return; + } - if(m_instanceIdToLaunch.isEmpty() && !m_profileToUse.isEmpty()) - { - std::cerr << "--account can only be used in combination with --launch!" << std::endl; - m_status = Application::Failed; - return; + if(!m_profileToUse.isEmpty()) + { + std::cerr << "--account can only be used in combination with --launch!" << std::endl; + m_status = Application::Failed; + return; + } + + if(m_offline) + { + std::cerr << "--offline can only be used in combination with --launch!" << std::endl; + m_status = Application::Failed; + return; + } + + if(!m_offlineName.isEmpty()) + { + std::cerr << "--offlineName can only be used in combination with --launch and --offline!" << std::endl; + m_status = Application::Failed; + return; + } + } + else { + // all the things invalid when trying to --launch + // online, and offline name is set + if(!m_offline && !m_offlineName.isEmpty()) { + std::cerr << "--offlineName can only be used in combination with --launch and --offline!" << std::endl; + m_status = Application::Failed; + return; + } } #if defined(Q_OS_MAC) @@ -473,6 +511,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) { launch.args["profile"] = m_profileToUse; } + if(m_offline) { + launch.args["offline_enabled"] = "true"; + launch.args["offline_name"] = m_offlineName; + } m_peerInstance->sendMessage(launch.serialize(), timeout); } m_status = Application::Succeeded; @@ -1030,6 +1072,7 @@ void Application::performMainStartupAction() { MinecraftServerTargetPtr serverToJoin = nullptr; MinecraftAccountPtr accountToUse = nullptr; + bool offline = m_offline; qDebug() << "<> Instance" << m_instanceIdToLaunch << "launching"; if(!m_serverToJoin.isEmpty()) @@ -1048,7 +1091,7 @@ void Application::performMainStartupAction() qDebug() << " Launching with account" << m_profileToUse; } - launch(inst, true, nullptr, serverToJoin, accountToUse); + launch(inst, !offline, nullptr, serverToJoin, accountToUse, m_offlineName); return; } } @@ -1121,6 +1164,8 @@ void Application::messageReceived(const QByteArray& message) QString id = received.args["id"]; QString server = received.args["server"]; QString profile = received.args["profile"]; + bool offline = received.args["offline_enabled"] == "true"; + QString offlineName = received.args["offline_name"]; InstancePtr instance; if(!id.isEmpty()) { @@ -1151,10 +1196,11 @@ void Application::messageReceived(const QByteArray& message) launch( instance, - true, + !offline, nullptr, serverObject, - accountObject + accountObject, + offlineName ); } else @@ -1252,7 +1298,8 @@ bool Application::launch( bool online, BaseProfilerFactory *profiler, MinecraftServerTargetPtr serverToJoin, - MinecraftAccountPtr accountToUse + MinecraftAccountPtr accountToUse, + const QString& offlineName ) { if(m_updateRunning) { @@ -1276,6 +1323,7 @@ bool Application::launch( controller->setProfiler(profiler); controller->setServerToJoin(serverToJoin); controller->setAccountToUse(accountToUse); + controller->setOfflineName(offlineName); if(window) { controller->setParentWidget(window); diff --git a/launcher/Application.h b/launcher/Application.h index 1b2a2b60..f9e523f9 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -154,7 +154,8 @@ public slots: bool online = true, BaseProfilerFactory *profiler = nullptr, MinecraftServerTargetPtr serverToJoin = nullptr, - MinecraftAccountPtr accountToUse = nullptr + MinecraftAccountPtr accountToUse = nullptr, + const QString &offlineName = QString() ); bool kill(InstancePtr instance); @@ -234,6 +235,8 @@ public: QString m_instanceIdToLaunch; QString m_serverToJoin; QString m_profileToUse; + bool m_offline = false; + QString m_offlineName; bool m_liveCheck = false; QUrl m_zipToImport; std::unique_ptr logFile; diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index ae88a282..17f6400b 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -126,28 +126,35 @@ void LaunchController::login() { } case AccountState::Online: { if(!m_session->wants_online) { - // we ask the user for a player name - bool ok = false; - QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString(); - QString usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName; - QString name = QInputDialog::getText( - m_parentWidget, - tr("Player name"), - tr("Choose your offline mode player name."), - QLineEdit::Normal, - usedname, - &ok - ); - if (!ok) - { - tryagain = false; - break; + QString usedname; + if(m_offlineName.isEmpty()) { + // we ask the user for a player name + bool ok = false; + QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString(); + usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName; + QString name = QInputDialog::getText( + m_parentWidget, + tr("Player name"), + tr("Choose your offline mode player name."), + QLineEdit::Normal, + usedname, + &ok + ); + if (!ok) + { + tryagain = false; + break; + } + if (name.length()) + { + usedname = name; + APPLICATION->settings()->set("LastOfflinePlayerName", usedname); + } } - if (name.length()) - { - usedname = name; - APPLICATION->settings()->set("LastOfflinePlayerName", usedname); + else { + usedname = m_offlineName; } + m_session->MakeOffline(usedname); // offline flavored game from here :3 } diff --git a/launcher/LaunchController.h b/launcher/LaunchController.h index 7ed4b09e..53a704c0 100644 --- a/launcher/LaunchController.h +++ b/launcher/LaunchController.h @@ -28,6 +28,10 @@ public: m_online = online; } + void setOfflineName(const QString &offlineName) { + m_offlineName = offlineName; + } + void setProfiler(BaseProfilerFactory *profiler) { m_profiler = profiler; } @@ -66,6 +70,7 @@ private slots: private: BaseProfilerFactory *m_profiler = nullptr; bool m_online = true; + QString m_offlineName; InstancePtr m_instance; QWidget * m_parentWidget = nullptr; InstanceWindow *m_console = nullptr; From c6b60969bb64211927a2514c1eb478fd80f2f250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 9 Jun 2022 23:50:30 +0200 Subject: [PATCH 2/2] NOISSUE update changelog for 0.6.16 --- changelog.md | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 242e8551..39e57465 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,36 @@ -# MultiMC 0.6.15 +# MultiMC 0.6.16 + +This brings some good and bad changes to modpack platforms, along with various fixes. + +We've added Modrinth as a directly supported modpack platform. It's nice, and the list of packs availale from it is slowly growing. + +We can no longer directly import FTB modpacks from the FTB platform. Instead, this has been replaced by import from the [FTB App](https://www.feed-the-beast.com/app). You can get FTB modpacks through the FTB App and then import them into MultiMC using the `FTB App Import` page in `Add Instance`. + +We can also no longer directly download CurseForge modpacks, although this should be only temporary (once the issues we have with the CurseForge API ToS are resolved, it will make a comeback). Currently, you can get CurseForge packs using the `FTB App Import`, just make sure you switch the FTB App to the CurseForge mode. The button for that isn't too obvious, look for the CurseForge logo. + +Aside from these changes, the release brings some general fixes. + +#### Changes, itemized. + +- Modrinth platform has been added, along with importing `.mrpack` files. +- FTB App Import has been added as a way to automate copying over modpacks installed using the FTB App. +- Curseforge platform and importing `.zip` files from the platform has been removed (replaced by FTB App Import). +- FTB platform has been removed (replaced by FTB App Import). +- MultiMC is now blocking passing the `-version` argument to the Java Runtime. This should stop some really strange (unaccounted for) things from happening. +- GH-3742: Added Quilt modloader installation button and support for importing Quilt-using modpacks in general. +- When the game crashes on Windows, MultiMC gives you a nicer representation of what the exit code could mean. +- Some odd corner cases when importing ATLauncher modpacks are now handled better. +- Custom player name for offline mode is now saved for your convenience. +- GH-3012: Added command line options to launch instances offline. + + Used like this: + ``` + ./MultiMC --launch 1.17.1 --offline --name Steve + ``` + +# Previous releases + +## MultiMC 0.6.15 This is mostly a bugfix release. @@ -27,8 +59,6 @@ This is mostly a bugfix release. - GH-4299: Fix crash when uploading screenshots. - Added the capability to copypaste screenshots as raw images (to image editors) and files (to file explorers). -# Previous releases - ## MultiMC 0.6.14 This further refines Microsoft account support, along with small fixes related to modpack platforms and Java runtime detection.