From 53a4395d5bc1e13091ec3e1a33c67eb9e3b5d39a Mon Sep 17 00:00:00 2001 From: Kaydax Date: Tue, 10 Oct 2023 20:14:11 -0400 Subject: [PATCH] Fix Yggdrasil error messages when not using Mojang Signed-off-by: Lenny McLennington --- .../minecraft/auth/steps/YggdrasilStep.cpp | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/launcher/minecraft/auth/steps/YggdrasilStep.cpp b/launcher/minecraft/auth/steps/YggdrasilStep.cpp index e1d33172..a8adfa66 100644 --- a/launcher/minecraft/auth/steps/YggdrasilStep.cpp +++ b/launcher/minecraft/auth/steps/YggdrasilStep.cpp @@ -1,5 +1,6 @@ #include "YggdrasilStep.h" +#include "minecraft/auth/AccountData.h" #include "minecraft/auth/AuthRequest.h" #include "minecraft/auth/Parsers.h" #include "minecraft/auth/Yggdrasil.h" @@ -15,7 +16,14 @@ YggdrasilStep::YggdrasilStep(AccountData* data, QString password) : AuthStep(dat YggdrasilStep::~YggdrasilStep() noexcept = default; QString YggdrasilStep::describe() { - return tr("Logging in with Mojang account."); + switch(m_data->type) { + case(AccountType::Mojang): + return tr("Logging in with Mojang account."); + case AccountType::AuthlibInjector: + return tr("Logging in with %1 account.").arg(m_data->authlibInjectorBaseUrl); + default: + break; + } } void YggdrasilStep::rehydrate() { @@ -32,7 +40,9 @@ void YggdrasilStep::perform() { } void YggdrasilStep::onAuthSucceeded() { - emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Mojang")); + emit m_data->type == AccountType::Mojang + ? finished(AccountTaskState::STATE_WORKING, tr("Logged in with Mojang")) + : finished(AccountTaskState::STATE_WORKING, tr("Logged in with %1").arg(m_data->authlibInjectorBaseUrl)); } void YggdrasilStep::onAuthFailed() { @@ -41,12 +51,32 @@ void YggdrasilStep::onAuthFailed() { // m_aborted = m_yggdrasil->m_aborted; auto state = m_yggdrasil->taskState(); - QString errorMessage = tr("Mojang user authentication failed."); + QString errorMessage = m_data->type == AccountType::Mojang + ? tr("Mojang user authentication failed.") + : tr("%1 user authentication failed").arg(m_data->authlibInjectorBaseUrl); // NOTE: soft error in the first step means 'offline' if(state == AccountTaskState::STATE_FAILED_SOFT) { state = AccountTaskState::STATE_OFFLINE; - errorMessage = tr("Mojang user authentication ended with a network error."); + switch(m_data->type) { + case AccountType::Mojang: + { + errorMessage = tr("Mojang user authentication ended with a network error."); + break; + } + case AccountType::AuthlibInjector: + { + if(m_data->authlibInjectorBaseUrl.isEmpty()) + { + errorMessage = tr("User authentication ended with a network error, did specify a url?"); + } else { + errorMessage = tr("%1 user authentication ended with a network error").arg(m_data->authlibInjectorBaseUrl); + } + break; + } + default: + break; + } } emit finished(state, errorMessage); }