diff options
Diffstat (limited to 'launcher/minecraft')
24 files changed, 194 insertions, 39 deletions
diff --git a/launcher/minecraft/Library.h b/launcher/minecraft/Library.h index 41d41a8b..0740a7ca 100644 --- a/launcher/minecraft/Library.h +++ b/launcher/minecraft/Library.h @@ -156,7 +156,7 @@ public: /* methods */ QStringList & failedLocalFiles, const QString & overridePath) const; private: /* methods */ - /// the default storage prefix used by MultiMC + /// the default storage prefix used by PolyMC static QString defaultStoragePrefix(); /// Get the prefix - root of the storage to be used @@ -177,23 +177,23 @@ protected: /* data */ /// DEPRECATED URL prefix of the maven repo where the file can be downloaded QString m_repositoryURL; - /// DEPRECATED: MultiMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined + /// DEPRECATED: PolyMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined QString m_absoluteURL; - /// MultiMC extension - filename override + /// PolyMC extension - filename override QString m_filename; - /// DEPRECATED MultiMC extension - display name + /// DEPRECATED PolyMC extension - display name QString m_displayname; /** - * MultiMC-specific type hint - modifies how the library is treated + * PolyMC-specific type hint - modifies how the library is treated */ QString m_hint; /** - * storage - by default the local libraries folder in multimc, but could be elsewhere - * MultiMC specific, because of FTB. + * storage - by default the local libraries folder in polymc, but could be elsewhere + * PolyMC specific, because of FTB. */ QString m_storagePrefix; @@ -215,3 +215,4 @@ protected: /* data */ /// MOJANG: container with Mojang style download info MojangLibraryDownloadInfo::Ptr m_mojangDownloads; }; + diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 0b3c049b..7327f9d5 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -445,7 +445,7 @@ QStringList MinecraftInstance::processMinecraftArgs( } // blatant self-promotion. - token_mapping["profile_name"] = token_mapping["version_name"] = "MultiMC5"; + token_mapping["profile_name"] = token_mapping["version_name"] = "PolyMC"; token_mapping["version_type"] = profile->getMinecraftVersionType(); diff --git a/launcher/minecraft/MinecraftLoadAndCheck.h b/launcher/minecraft/MinecraftLoadAndCheck.h index bfeae46b..d9af3ace 100644 --- a/launcher/minecraft/MinecraftLoadAndCheck.h +++ b/launcher/minecraft/MinecraftLoadAndCheck.h @@ -20,7 +20,7 @@ #include <QUrl> #include "tasks/Task.h" -#include <quazip.h> +#include <quazip/quazip.h> #include "QObjectPtr.h" diff --git a/launcher/minecraft/MinecraftUpdate.h b/launcher/minecraft/MinecraftUpdate.h index fadebff9..9ebef656 100644 --- a/launcher/minecraft/MinecraftUpdate.h +++ b/launcher/minecraft/MinecraftUpdate.h @@ -22,7 +22,7 @@ #include "net/NetJob.h" #include "tasks/Task.h" #include "minecraft/VersionFilterData.h" -#include <quazip.h> +#include <quazip/quazip.h> class MinecraftVersion; class MinecraftInstance; diff --git a/launcher/minecraft/VersionFile.h b/launcher/minecraft/VersionFile.h index b79fcd4f..239a4069 100644 --- a/launcher/minecraft/VersionFile.h +++ b/launcher/minecraft/VersionFile.h @@ -27,19 +27,19 @@ public: /* methods */ void applyTo(LaunchProfile* profile); public: /* data */ - /// MultiMC: order hint for this version file if no explicit order is set + /// PolyMC: order hint for this version file if no explicit order is set int order = 0; - /// MultiMC: human readable name of this package + /// PolyMC: human readable name of this package QString name; - /// MultiMC: package ID of this package + /// PolyMC: package ID of this package QString uid; - /// MultiMC: version of this package + /// PolyMC: version of this package QString version; - /// MultiMC: DEPRECATED dependency on a Minecraft version + /// PolyMC: DEPRECATED dependency on a Minecraft version QString dependsOnMinecraftVersion; /// Mojang: DEPRECATED used to version the Mojang version format @@ -51,7 +51,7 @@ public: /* data */ /// Mojang: class to launch Minecraft with QString mainClass; - /// MultiMC: class to launch legacy Minecraft with (embed in a custom window) + /// PolyMC: class to launch legacy Minecraft with (embed in a custom window) QString appletClass; /// Mojang: Minecraft launch arguments (may contain placeholders for variable substitution) @@ -69,35 +69,35 @@ public: /* data */ /// Mojang: DEPRECATED asset group to be used with Minecraft QString assets; - /// MultiMC: list of tweaker mod arguments for launchwrapper + /// PolyMC: list of tweaker mod arguments for launchwrapper QStringList addTweakers; /// Mojang: list of libraries to add to the version QList<LibraryPtr> libraries; - /// MultiMC: list of maven files to put in the libraries folder, but not in classpath + /// PolyMC: list of maven files to put in the libraries folder, but not in classpath QList<LibraryPtr> mavenFiles; /// The main jar (Minecraft version library, normally) LibraryPtr mainJar; - /// MultiMC: list of attached traits of this version file - used to enable features + /// PolyMC: list of attached traits of this version file - used to enable features QSet<QString> traits; - /// MultiMC: list of jar mods added to this version + /// PolyMC: list of jar mods added to this version QList<LibraryPtr> jarMods; - /// MultiMC: list of mods added to this version + /// PolyMC: list of mods added to this version QList<LibraryPtr> mods; /** - * MultiMC: set of packages this depends on + * PolyMC: set of packages this depends on * NOTE: this is shared with the meta format!!! */ Meta::RequireSet requires; /** - * MultiMC: set of packages this conflicts with + * PolyMC: set of packages this conflicts with * NOTE: this is shared with the meta format!!! */ Meta::RequireSet conflicts; @@ -112,3 +112,4 @@ public: // Mojang: extended asset index download information std::shared_ptr<MojangAssetIndexInfo> mojangAssetIndex; }; + diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp index a2b4dac7..2937c116 100644 --- a/launcher/minecraft/World.cpp +++ b/launcher/minecraft/World.cpp @@ -26,9 +26,9 @@ #include <io/stream_reader.h> #include <tag_string.h> #include <tag_primitive.h> -#include <quazip.h> -#include <quazipfile.h> -#include <quazipdir.h> +#include <quazip/quazip.h> +#include <quazip/quazipfile.h> +#include <quazip/quazipdir.h> #include <QCoreApplication> diff --git a/launcher/minecraft/auth/AccountData.cpp b/launcher/minecraft/auth/AccountData.cpp index 7526c951..9b84fe1a 100644 --- a/launcher/minecraft/auth/AccountData.cpp +++ b/launcher/minecraft/auth/AccountData.cpp @@ -314,6 +314,8 @@ bool AccountData::resumeStateFromV3(QJsonObject data) { type = AccountType::MSA; } else if (typeS == "Mojang") { type = AccountType::Mojang; + } else if (typeS == "Offline") { + type = AccountType::Offline; } else { qWarning() << "Failed to parse account data: type is not recognized."; return false; @@ -363,6 +365,9 @@ QJsonObject AccountData::saveState() const { tokenToJSONV3(output, xboxApiToken, "xrp-main"); tokenToJSONV3(output, mojangservicesToken, "xrp-mc"); } + else if (type == AccountType::Offline) { + output["type"] = "Offline"; + } tokenToJSONV3(output, yggdrasilToken, "ygg"); profileToJSONV3(output, minecraftProfile, "profile"); @@ -371,7 +376,7 @@ QJsonObject AccountData::saveState() const { } QString AccountData::userName() const { - if(type != AccountType::Mojang) { + if(type == AccountType::MSA) { return QString(); } return yggdrasilToken.extra["userName"].toString(); @@ -427,6 +432,9 @@ QString AccountData::accountDisplayString() const { case AccountType::Mojang: { return userName(); } + case AccountType::Offline: { + return userName(); + } case AccountType::MSA: { if(xboxApiToken.extra.contains("gtg")) { return xboxApiToken.extra["gtg"].toString(); diff --git a/launcher/minecraft/auth/AccountData.h b/launcher/minecraft/auth/AccountData.h index abf84e43..606c1ad1 100644 --- a/launcher/minecraft/auth/AccountData.h +++ b/launcher/minecraft/auth/AccountData.h @@ -38,7 +38,8 @@ struct MinecraftProfile { enum class AccountType { MSA, - Mojang + Mojang, + Offline }; enum class AccountState { diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp index ef8b435d..04470e1c 100644 --- a/launcher/minecraft/auth/AccountList.cpp +++ b/launcher/minecraft/auth/AccountList.cpp @@ -302,7 +302,7 @@ QVariant AccountList::data(const QModelIndex &index, int role) const } case MigrationColumn: { - if(account->isMSA()) { + if(account->isMSA() || account->isOffline()) { return tr("N/A", "Can Migrate?"); } if (account->canMigrate()) { diff --git a/launcher/minecraft/auth/AccountList.h b/launcher/minecraft/auth/AccountList.h index fa1e7431..025926ae 100644 --- a/launcher/minecraft/auth/AccountList.h +++ b/launcher/minecraft/auth/AccountList.h @@ -24,7 +24,7 @@ /*! * List of available Mojang accounts. - * This should be loaded in the background by MultiMC on startup. + * This should be loaded in the background by PolyMC on startup. */ class AccountList : public QAbstractListModel { @@ -158,3 +158,4 @@ protected: */ bool m_autosave = false; }; + diff --git a/launcher/minecraft/auth/AuthRequest.cpp b/launcher/minecraft/auth/AuthRequest.cpp index 459d2354..feface80 100644 --- a/launcher/minecraft/auth/AuthRequest.cpp +++ b/launcher/minecraft/auth/AuthRequest.cpp @@ -44,7 +44,7 @@ void AuthRequest::onRequestFinished() { if (reply_ != qobject_cast<QNetworkReply *>(sender())) { return; } - httpStatus_ = 200; + httpStatus_ = reply_->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); finish(); } diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index ed9e945e..ffc81ed8 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -30,6 +30,7 @@ #include "flows/MSA.h" #include "flows/Mojang.h" +#include "flows/Offline.h" MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) { data.internalId = QUuid::createUuid().toString().remove(QRegExp("[{}-]")); @@ -68,6 +69,23 @@ MinecraftAccountPtr MinecraftAccount::createBlankMSA() return account; } +MinecraftAccountPtr MinecraftAccount::createOffline(const QString &username) +{ + MinecraftAccountPtr account = new MinecraftAccount(); + account->data.type = AccountType::Offline; + account->data.yggdrasilToken.token = "offline"; + account->data.yggdrasilToken.validity = Katabasis::Validity::Certain; + account->data.yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc(); + account->data.yggdrasilToken.extra["userName"] = username; + account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]")); + account->data.minecraftEntitlement.ownsMinecraft = true; + account->data.minecraftEntitlement.canPlayMinecraft = true; + account->data.minecraftProfile.id = QUuid::createUuid().toString().remove(QRegExp("[{}-]")); + account->data.minecraftProfile.name = username; + account->data.minecraftProfile.validity = Katabasis::Validity::Certain; + return account; +} + QJsonObject MinecraftAccount::saveToJson() const { @@ -111,6 +129,16 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::loginMSA() { return m_currentTask; } +shared_qobject_ptr<AccountTask> MinecraftAccount::loginOffline() { + Q_ASSERT(m_currentTask.get() == nullptr); + + m_currentTask.reset(new OfflineLogin(&data)); + connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded())); + connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString))); + emit activityChanged(true); + return m_currentTask; +} + shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() { if(m_currentTask) { return m_currentTask; @@ -119,6 +147,9 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() { if(data.type == AccountType::MSA) { m_currentTask.reset(new MSASilent(&data)); } + else if(data.type == AccountType::Offline) { + m_currentTask.reset(new OfflineRefresh(&data)); + } else { m_currentTask.reset(new MojangRefresh(&data)); } diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index 4ac0a3e5..6592f9c0 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -41,7 +41,7 @@ Q_DECLARE_METATYPE(MinecraftAccountPtr) * A profile within someone's Mojang account. * * Currently, the profile system has not been implemented by Mojang yet, - * but we might as well add some things for it in MultiMC right now so + * but we might as well add some things for it in PolyMC right now so * we don't have to rip the code to pieces to add it later. */ struct AccountProfile @@ -73,6 +73,8 @@ public: /* construction */ static MinecraftAccountPtr createBlankMSA(); + static MinecraftAccountPtr createOffline(const QString &username); + static MinecraftAccountPtr loadFromJsonV2(const QJsonObject &json); static MinecraftAccountPtr loadFromJsonV3(const QJsonObject &json); @@ -89,6 +91,8 @@ public: /* manipulation */ shared_qobject_ptr<AccountTask> loginMSA(); + shared_qobject_ptr<AccountTask> loginOffline(); + shared_qobject_ptr<AccountTask> refresh(); shared_qobject_ptr<AccountTask> currentTask(); @@ -128,6 +132,10 @@ public: /* queries */ return data.type == AccountType::MSA; } + bool isOffline() const { + return data.type == AccountType::Offline; + } + bool ownsMinecraft() const { return data.minecraftEntitlement.ownsMinecraft; } @@ -149,6 +157,10 @@ public: /* queries */ return "msa"; } break; + case AccountType::Offline: { + return "offline"; + } + break; default: { return "unknown"; } @@ -198,3 +210,4 @@ slots: void authSucceeded(); void authFailed(QString reason); }; + diff --git a/launcher/minecraft/auth/Parsers.cpp b/launcher/minecraft/auth/Parsers.cpp index ed31e934..2dd36562 100644 --- a/launcher/minecraft/auth/Parsers.cpp +++ b/launcher/minecraft/auth/Parsers.cpp @@ -94,7 +94,7 @@ bool parseXTokenResponse(QByteArray & data, Katabasis::Token &output, QString na return false; } if(!getString(obj.value("Token"), output.token)) { - qWarning() << "User Token is not a timestamp"; + qWarning() << "User Token is not a string"; return false; } auto arrayVal = obj.value("DisplayClaims").toObject().value("xui"); diff --git a/launcher/minecraft/auth/flows/Offline.cpp b/launcher/minecraft/auth/flows/Offline.cpp new file mode 100644 index 00000000..fc614a8c --- /dev/null +++ b/launcher/minecraft/auth/flows/Offline.cpp @@ -0,0 +1,17 @@ +#include "Offline.h" + +#include "minecraft/auth/steps/OfflineStep.h" + +OfflineRefresh::OfflineRefresh( + AccountData *data, + QObject *parent +) : AuthFlow(data, parent) { + m_steps.append(new OfflineStep(m_data)); +} + +OfflineLogin::OfflineLogin( + AccountData *data, + QObject *parent +) : AuthFlow(data, parent) { + m_steps.append(new OfflineStep(m_data)); +} diff --git a/launcher/minecraft/auth/flows/Offline.h b/launcher/minecraft/auth/flows/Offline.h new file mode 100644 index 00000000..5d1f83a4 --- /dev/null +++ b/launcher/minecraft/auth/flows/Offline.h @@ -0,0 +1,22 @@ +#pragma once +#include "AuthFlow.h" + +class OfflineRefresh : public AuthFlow +{ + Q_OBJECT +public: + explicit OfflineRefresh( + AccountData *data, + QObject *parent = 0 + ); +}; + +class OfflineLogin : public AuthFlow +{ + Q_OBJECT +public: + explicit OfflineLogin( + AccountData *data, + QObject *parent = 0 + ); +}; diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index bc10aa4e..779aee43 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -14,7 +14,7 @@ using Activity = Katabasis::Activity; MSAStep::MSAStep(AccountData* data, Action action) : AuthStep(data), m_action(action) { OAuth2::Options opts; opts.scope = "XboxLive.signin offline_access"; - opts.clientIdentifier = BuildConfig.MSA_CLIENT_ID; + opts.clientIdentifier = APPLICATION->getMSAClientID(); opts.authorizationUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; diff --git a/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp b/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp index 9fef99b0..add91659 100644 --- a/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp +++ b/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp @@ -56,6 +56,14 @@ void MinecraftProfileStep::onRequestDone( return; } if (error != QNetworkReply::NoError) { + qWarning() << "Error getting profile:"; + qWarning() << " HTTP Status: " << requestor->httpStatus_; + qWarning() << " Internal error no.: " << error; + qWarning() << " Error string: " << requestor->errorString_; + + qWarning() << " Response:"; + qWarning() << QString::fromUtf8(data); + emit finished( AccountTaskState::STATE_FAILED_SOFT, tr("Minecraft Java profile acquisition failed.") diff --git a/launcher/minecraft/auth/steps/OfflineStep.cpp b/launcher/minecraft/auth/steps/OfflineStep.cpp new file mode 100644 index 00000000..dc092bfd --- /dev/null +++ b/launcher/minecraft/auth/steps/OfflineStep.cpp @@ -0,0 +1,18 @@ +#include "OfflineStep.h" + +#include "Application.h" + +OfflineStep::OfflineStep(AccountData* data) : AuthStep(data) {} +OfflineStep::~OfflineStep() noexcept = default; + +QString OfflineStep::describe() { + return tr("Creating offline account."); +} + +void OfflineStep::rehydrate() { + // NOOP +} + +void OfflineStep::perform() { + emit finished(AccountTaskState::STATE_WORKING, tr("Created offline account.")); +} diff --git a/launcher/minecraft/auth/steps/OfflineStep.h b/launcher/minecraft/auth/steps/OfflineStep.h new file mode 100644 index 00000000..436597cd --- /dev/null +++ b/launcher/minecraft/auth/steps/OfflineStep.h @@ -0,0 +1,19 @@ +#pragma once +#include <QObject> + +#include "QObjectPtr.h" +#include "minecraft/auth/AuthStep.h" + +#include <katabasis/DeviceFlow.h> + +class OfflineStep : public AuthStep { + Q_OBJECT +public: + explicit OfflineStep(AccountData *data); + virtual ~OfflineStep() noexcept; + + void perform() override; + void rehydrate() override; + + QString describe() override; +}; diff --git a/launcher/minecraft/launch/ExtractNatives.cpp b/launcher/minecraft/launch/ExtractNatives.cpp index 8cd439b1..7d5f4179 100644 --- a/launcher/minecraft/launch/ExtractNatives.cpp +++ b/launcher/minecraft/launch/ExtractNatives.cpp @@ -17,8 +17,8 @@ #include <minecraft/MinecraftInstance.h> #include <launch/LaunchTask.h> -#include <quazip.h> -#include <quazipdir.h> +#include <quazip/quazip.h> +#include <quazip/quazipdir.h> #include "MMCZip.h" #include "FileSystem.h" #include <QDir> diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp index 8fd11eca..f461b847 100644 --- a/launcher/minecraft/launch/LauncherPartLaunch.cpp +++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp @@ -25,6 +25,19 @@ LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent) { + if (APPLICATION->settings()->get("CloseAfterLaunch").toBool()) + { + std::shared_ptr<QMetaObject::Connection> connection{new QMetaObject::Connection}; + *connection = connect(&m_process, &LoggedProcess::log, this, [=](QStringList lines, MessageLevel::Enum level) { + qDebug() << lines; + if (lines.filter(QRegularExpression(".*Setting user.+", QRegularExpression::CaseInsensitiveOption)).length() != 0) + { + APPLICATION->closeAllWindows(); + disconnect(*connection); + } + }); + } + connect(&m_process, &LoggedProcess::log, this, &LauncherPartLaunch::logLines); connect(&m_process, &LoggedProcess::stateChanged, this, &LauncherPartLaunch::on_state); } @@ -155,6 +168,8 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state) } case LoggedProcess::Finished: { + if (APPLICATION->settings()->get("CloseAfterLaunch").toBool()) + APPLICATION->showMainWindow(); m_parent->setPid(-1); // if the exit code wasn't 0, report this as a crash auto exitCode = m_process.exitCode(); diff --git a/launcher/minecraft/launch/MinecraftServerTarget.cpp b/launcher/minecraft/launch/MinecraftServerTarget.cpp index 0f98f356..78a33359 100644 --- a/launcher/minecraft/launch/MinecraftServerTarget.cpp +++ b/launcher/minecraft/launch/MinecraftServerTarget.cpp @@ -23,7 +23,7 @@ MinecraftServerTarget MinecraftServerTarget::parse(const QString &fullAddress) { // The logic below replicates the exact logic minecraft uses for parsing server addresses. // While the conversion is not lossless and eats errors, it ensures the same behavior - // within Minecraft and MultiMC when entering server addresses. + // within Minecraft and PolyMC when entering server addresses. if (fullAddress.startsWith("[")) { int bracket = fullAddress.indexOf("]"); diff --git a/launcher/minecraft/mod/LocalModParseTask.cpp b/launcher/minecraft/mod/LocalModParseTask.cpp index 8ac5885f..757a2187 100644 --- a/launcher/minecraft/mod/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/LocalModParseTask.cpp @@ -4,8 +4,8 @@ #include <QJsonObject> #include <QJsonArray> #include <QJsonValue> -#include <quazip.h> -#include <quazipfile.h> +#include <quazip/quazip.h> +#include <quazip/quazipfile.h> #include <toml.h> #include "settings/INIFile.h" |