From 27f276ef13f49b4d21b6c17db5d4cd5e404ea259 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 31 Oct 2021 21:42:06 +0100 Subject: GH-1795 add terminal launch option to use a specific Minecraft profile Used like this: ``` ./MultiMC --launch 1.17.1 --profile MultiMCTest --server mc.hypixel.net ``` --- launcher/minecraft/auth/AccountList.cpp | 10 ++++++++++ launcher/minecraft/auth/AccountList.h | 1 + 2 files changed, 11 insertions(+) (limited to 'launcher/minecraft/auth') diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp index 76af0ac0..a76cac55 100644 --- a/launcher/minecraft/auth/AccountList.cpp +++ b/launcher/minecraft/auth/AccountList.cpp @@ -47,6 +47,16 @@ int AccountList::findAccountByProfileId(const QString& profileId) const { return -1; } +MinecraftAccountPtr AccountList::getAccountByProfileName(const QString& profileName) const { + for (int i = 0; i < count(); i++) { + MinecraftAccountPtr account = at(i); + if (account->profileName() == profileName) { + return account; + } + } + return nullptr; +} + const MinecraftAccountPtr AccountList::at(int i) const { return MinecraftAccountPtr(m_accounts.at(i)); diff --git a/launcher/minecraft/auth/AccountList.h b/launcher/minecraft/auth/AccountList.h index ed08bb1d..e275eb17 100644 --- a/launcher/minecraft/auth/AccountList.h +++ b/launcher/minecraft/auth/AccountList.h @@ -62,6 +62,7 @@ public: void addAccount(const MinecraftAccountPtr account); void removeAccount(QModelIndex index); int findAccountByProfileId(const QString &profileId) const; + MinecraftAccountPtr getAccountByProfileName(const QString &profileName) const; /*! * Sets the path to load/save the list file from/to. -- cgit