mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-26 02:25:03 +00:00
Authlib injector, local auth server and ely by accounts support (#31)
* Add injector * Add uuid generation for profile * Add auth server emulator * Start auth server on random port and bypass it to injector * Run injector only when account type is dummy * Clean authlib injector * Add ely by authentication * Remove old comments * Add response status text to auth server * Fix json value access as done by @maximmasterr
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "minecraft/launch/ClaimAccount.h"
|
||||
#include "minecraft/launch/ReconstructAssets.h"
|
||||
#include "minecraft/launch/ScanModFolders.h"
|
||||
#include "minecraft/launch/InjectAuthlib.h"
|
||||
#include "java/launch/CheckJava.h"
|
||||
#include "java/JavaUtils.h"
|
||||
#include "meta/Index.h"
|
||||
@@ -50,7 +51,7 @@ class OrSetting : public Setting
|
||||
Q_OBJECT
|
||||
public:
|
||||
OrSetting(QString id, std::shared_ptr<Setting> a, std::shared_ptr<Setting> b)
|
||||
:Setting({id}, false), m_a(a), m_b(b)
|
||||
:Setting({id}, false), m_a(a), m_b(b)
|
||||
{
|
||||
}
|
||||
virtual QVariant get() const
|
||||
@@ -297,6 +298,8 @@ QStringList MinecraftInstance::javaArguments() const
|
||||
{
|
||||
QStringList args;
|
||||
|
||||
args.append(m_injector->javaArg);
|
||||
|
||||
// custom args go first. we want to override them if we have our own here.
|
||||
args.append(extraArguments());
|
||||
|
||||
@@ -401,7 +404,7 @@ static QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
||||
}
|
||||
|
||||
QStringList MinecraftInstance::processMinecraftArgs(
|
||||
AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) const
|
||||
AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) const
|
||||
{
|
||||
auto profile = m_components->getProfile();
|
||||
QString args_pattern = profile->getMinecraftArguments();
|
||||
@@ -481,9 +484,9 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS
|
||||
|
||||
// generic minecraft params
|
||||
for (auto param : processMinecraftArgs(
|
||||
session,
|
||||
nullptr /* When using a launch script, the server parameters are handled by it*/
|
||||
))
|
||||
session,
|
||||
nullptr /* When using a launch script, the server parameters are handled by it*/
|
||||
))
|
||||
{
|
||||
launchScript += "param " + param + "\n";
|
||||
}
|
||||
@@ -601,10 +604,10 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
||||
out << QString("%1:").arg(label);
|
||||
auto modList = model.allMods();
|
||||
std::sort(modList.begin(), modList.end(), [](Mod &a, Mod &b) {
|
||||
auto aName = a.filename().completeBaseName();
|
||||
auto bName = b.filename().completeBaseName();
|
||||
return aName.localeAwareCompare(bName) < 0;
|
||||
});
|
||||
auto aName = a.filename().completeBaseName();
|
||||
auto bName = b.filename().completeBaseName();
|
||||
return aName.localeAwareCompare(bName) < 0;
|
||||
});
|
||||
for(auto & mod: modList)
|
||||
{
|
||||
if(mod.type() == Mod::MOD_FOLDER)
|
||||
@@ -741,12 +744,12 @@ MessageLevel::Enum MinecraftInstance::guessLevel(const QString &line, MessageLev
|
||||
return MessageLevel::Fatal;
|
||||
//NOTE: this diverges from the real regexp. no unicode, the first section is + instead of *
|
||||
static const QString javaSymbol = "([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$][a-zA-Z\\d_$]*";
|
||||
if (line.contains("Exception in thread")
|
||||
if (line.contains("Exception in thread")
|
||||
|| line.contains(QRegularExpression("\\s+at " + javaSymbol))
|
||||
|| line.contains(QRegularExpression("Caused by: " + javaSymbol))
|
||||
|| line.contains(QRegularExpression("([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$]?[a-zA-Z\\d_$]*(Exception|Error|Throwable)"))
|
||||
|| line.contains(QRegularExpression("... \\d+ more$"))
|
||||
)
|
||||
)
|
||||
return MessageLevel::Error;
|
||||
return level;
|
||||
}
|
||||
@@ -810,19 +813,19 @@ shared_qobject_ptr<Task> MinecraftInstance::createUpdateTask(Net::Mode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case Net::Mode::Offline:
|
||||
{
|
||||
return shared_qobject_ptr<Task>(new MinecraftLoadAndCheck(this));
|
||||
}
|
||||
case Net::Mode::Online:
|
||||
{
|
||||
return shared_qobject_ptr<Task>(new MinecraftUpdate(this));
|
||||
}
|
||||
case Net::Mode::Offline:
|
||||
{
|
||||
return shared_qobject_ptr<Task>(new MinecraftLoadAndCheck(this));
|
||||
}
|
||||
case Net::Mode::Online:
|
||||
{
|
||||
return shared_qobject_ptr<Task>(new MinecraftUpdate(this));
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin)
|
||||
shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin, quint16 localAuthServerPort)
|
||||
{
|
||||
// FIXME: get rid of shared_from_this ...
|
||||
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
|
||||
@@ -914,6 +917,17 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
||||
process->appendStep(new ReconstructAssets(pptr));
|
||||
}
|
||||
|
||||
// authlib patch
|
||||
if (session->m_accountPtr->loginType() != "mojang")
|
||||
{
|
||||
auto step = new InjectAuthlib(pptr, &m_injector);
|
||||
if(session->m_accountPtr->loginType() == "dummy")
|
||||
step->setAuthServer(((QString)"http://localhost:%1").arg(localAuthServerPort));
|
||||
else if(session->m_accountPtr->loginType() == "elyby")
|
||||
step->setAuthServer(((QString) "ely.by").arg(localAuthServerPort));
|
||||
process->appendStep(step);
|
||||
}
|
||||
|
||||
{
|
||||
// actually launch the game
|
||||
auto method = launchMethod();
|
||||
|
||||
Reference in New Issue
Block a user