aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/auth
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-10-31 21:42:06 +0100
committerPetr Mrázek <peterix@gmail.com>2021-10-31 21:43:33 +0100
commit27f276ef13f49b4d21b6c17db5d4cd5e404ea259 (patch)
treeec4f42a099b6f3df467536b0c9a9ac9e0677ab53 /launcher/minecraft/auth
parent393d17b8d383d7514b45ba980cc0246859bad085 (diff)
downloadPrismLauncher-27f276ef13f49b4d21b6c17db5d4cd5e404ea259.tar.gz
PrismLauncher-27f276ef13f49b4d21b6c17db5d4cd5e404ea259.tar.bz2
PrismLauncher-27f276ef13f49b4d21b6c17db5d4cd5e404ea259.zip
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 ```
Diffstat (limited to 'launcher/minecraft/auth')
-rw-r--r--launcher/minecraft/auth/AccountList.cpp10
-rw-r--r--launcher/minecraft/auth/AccountList.h1
2 files changed, 11 insertions, 0 deletions
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.