diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/logic/minecraft/MinecraftInstance.cpp | 2 | ||||
-rw-r--r-- | api/logic/minecraft/auth/MojangAccount.cpp | 15 | ||||
-rw-r--r-- | api/logic/minecraft/auth/MojangAccount.h | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index 28073edf..4617b09f 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -821,7 +821,7 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt } else { - process->appendStep(new Update(pptr, Net::Mode::Offline)); + process->appendStep(new Update(pptr, Net::Mode::Online)); } // if there are any jar mods diff --git a/api/logic/minecraft/auth/MojangAccount.cpp b/api/logic/minecraft/auth/MojangAccount.cpp index 657e0009..28f31266 100644 --- a/api/logic/minecraft/auth/MojangAccount.cpp +++ b/api/logic/minecraft/auth/MojangAccount.cpp @@ -19,6 +19,7 @@ #include "flows/RefreshTask.h" #include "flows/AuthenticateTask.h" +#include <QCryptographicHash> #include <QUuid> #include <QJsonObject> #include <QJsonArray> @@ -103,6 +104,20 @@ MojangAccountPtr MojangAccount::createFromUsername(const QString &username) return account; } +MojangAccountPtr MojangAccount::createFromUsernameOffline(const QString &username) +{ + MojangAccountPtr account(new MojangAccount()); + account->m_clientToken = "ff64ff64ff64ff64ff64ff64ff64ff64"; + account->m_accessToken = "ff64ff64ff64ff64ff64ff64ff64ff64"; + account->m_username = username; + QList<AccountProfile> profiles; + QString uuid = QCryptographicHash::hash(username.toLocal8Bit(), QCryptographicHash::Md5).toHex(); + profiles.append({uuid, username, false}); + account->m_profiles = profiles; + account->setCurrentProfile(uuid); + return account; +} + QJsonObject MojangAccount::saveToJson() const { QJsonObject json; diff --git a/api/logic/minecraft/auth/MojangAccount.h b/api/logic/minecraft/auth/MojangAccount.h index 7006435e..92679076 100644 --- a/api/logic/minecraft/auth/MojangAccount.h +++ b/api/logic/minecraft/auth/MojangAccount.h @@ -77,6 +77,9 @@ public: /* construction */ //! Creates an empty account for the specified user name. static MojangAccountPtr createFromUsername(const QString &username); + //! Creates an offline account for the specified user name. + static MojangAccountPtr createFromUsernameOffline(const QString &username); + //! Loads a MojangAccount from the given JSON object. static MojangAccountPtr loadFromJson(const QJsonObject &json); |