Skip to content

Commit

Permalink
Apply Ely.by patch to 8.0
Browse files Browse the repository at this point in the history
Closes #4
  • Loading branch information
Octol1ttle committed Nov 9, 2023
1 parent 9d4f727 commit f2b3ce2
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 145 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/codeql.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/winget.yml

This file was deleted.

51 changes: 4 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,14 @@
</p>

<p align="center">
Prism Launcher is a custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once.<br />
<br />This is a <b>fork</b> of the MultiMC Launcher and is <b>not</b> endorsed by it.
This <b>fork</b> of Prism Launcher replaces legacy Mojang accounts with Ely.by accounts<br />
<br />This is <b>not</b> endorsed by Prism Launcher.
</p>

## Installation

<a href="https://repology.org/project/prismlauncher/versions">
<img src="https://repology.org/badge/vertical-allrepos/prismlauncher.svg" alt="Packaging status" align="right">
</a>

- All downloads and instructions for Prism Launcher can be found on our [Website](https://prismlauncher.org/download).
- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) tab (this also includes the pull requests status).

### Development Builds

Please understand that these builds are not intended for most users. There may be bugs, and other instabilities. You have been warned.

There are development builds available through:

- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (includes builds from pull requests opened by contribuitors)
- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) (this will always point only to the latest version of develop)

These have debug information in the binaries, so their file sizes are relatively larger.

Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS**.

For **Arch**, **Debian**, **Fedora**, **OpenSUSE (Tumbleweed)** and **Gentoo**, respectively, you can use these packages for the latest development versions:

[![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--git-1793D1?label=AUR&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-git) [![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--qt5--git-1793D1?label=AUR&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-qt5-git) [![prismlauncher-git](https://img.shields.io/badge/mpr-prismlauncher--git-A80030?label=MPR&logo=debian&logoColor=white)](https://mpr.makedeb.org/packages/prismlauncher-git)<br />[![prismlauncher-nightly](https://img.shields.io/badge/copr-prismlauncher--nightly-51A2DA?label=COPR&logo=fedora&logoColor=white)](https://copr.fedorainfracloud.org/coprs/g3tchoo/prismlauncher/) [![prismlauncher-nightly](https://img.shields.io/badge/OBS-prismlauncher--nightly-3AB6A9?logo=opensuse&logoColor=white)](https://build.opensuse.org/project/show/home:getchoo) [![prismlauncher-9999](https://img.shields.io/badge/gentoo-prismlauncher--9999-4D4270?label=Gentoo&logo=gentoo&logoColor=white)](https://packages.gentoo.org/packages/games-action/prismlauncher)

These packages are also available to all the distributions based on the ones mentioned above.

## Community & Support

Feel free to create a GitHub issue if you find a bug or want to suggest a new feature. We have multiple community spaces where other community members can help you:

- **Our Discord server:**

[![Prism Launcher Discord server](https://discordapp.com/api/guilds/1031648380885147709/widget.png?style=banner3)](https://prismlauncher.org/discord)

- **Our Matrix space:**

[![Prism Launcher Space](https://img.shields.io/matrix/prismlauncher:matrix.org?style=for-the-badge&label=Matrix%20Space&logo=matrix&color=purple)](https://prismlauncher.org/matrix)

- **Our Subreddit:**

[![r/PrismLauncher](https://img.shields.io/reddit/subreddit-subscribers/prismlauncher?style=for-the-badge&logo=reddit)](https://prismlauncher.org/reddit)

## Translations

The translation effort for Prism Launcher is hosted on [Weblate](https://hosted.weblate.org/projects/prismlauncher/launcher/) and information about translating Prism Launcher is available at <https://github.com/PrismLauncher/Translations>.
- All downloads can be found [here](https://github.com/Octol1ttle/PrismLauncher-elyby/releases/latest).
- Last build status can be found in the [GitHub Actions](https://github.com/Octol1ttle/PrismLauncher-elyby/actions).

## Building

Expand Down
2 changes: 1 addition & 1 deletion buildconfig/BuildConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Config {

QString RESOURCE_BASE = "https://resources.download.minecraft.net/";
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
QString AUTH_BASE = "https://authserver.mojang.com/";
QString AUTH_BASE = "https://authserver.ely.by/auth";
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
QString FMLLIBS_BASE_URL = "https://files.prismlauncher.org/fmllibs/"; // FIXME: move into CMakeLists
QString TRANSLATIONS_BASE_URL = "https://i18n.prismlauncher.org/"; // FIXME: move into CMakeLists
Expand Down
1 change: 1 addition & 0 deletions injector-download.url
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/yushijinhun/authlib-injector/releases/download/v1.2.4/authlib-injector-1.2.4.jar
4 changes: 2 additions & 2 deletions launcher/LaunchController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void LaunchController::decideAccount()
if (accounts->count() <= 0) {
// Tell the user they need to log in at least one account in order to play.
auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"),
tr("In order to play Minecraft, you must have at least one Microsoft or Mojang "
"account logged in. Mojang accounts can only be used offline. "
tr("In order to play Minecraft, you must have at least one Microsoft or Ely.by "
"account logged in. "
"Would you like to open the account manager to add an account now?"),
QMessageBox::Information, QMessageBox::Yes | QMessageBox::No)
->exec();
Expand Down
4 changes: 2 additions & 2 deletions launcher/minecraft/auth/AccountData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ bool AccountData::resumeStateFromV2(QJsonObject data)
{
// The JSON object must at least have a username for it to be valid.
if (!data.value("username").isString()) {
qCritical() << "Can't load Mojang account info from JSON object. Username field is missing or of the wrong type.";
qCritical() << "Can't load Ely.by account info from JSON object. Username field is missing or of the wrong type.";
return false;
}

Expand All @@ -292,7 +292,7 @@ bool AccountData::resumeStateFromV2(QJsonObject data)

QJsonArray profileArray = data.value("profiles").toArray();
if (profileArray.size() < 1) {
qCritical() << "Can't load Mojang account with username \"" << userName << "\". No profiles found.";
qCritical() << "Can't load Ely.by account with username \"" << userName << "\". No profiles found.";
return false;
}

Expand Down
12 changes: 7 additions & 5 deletions launcher/minecraft/auth/AccountList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ int AccountList::findAccountByProfileId(const QString& profileId) const

MinecraftAccountPtr AccountList::getAccountByProfileName(const QString& profileName) const
{
MinecraftAccountPtr toReturn = nullptr;
for (int i = 0; i < count(); i++) {
MinecraftAccountPtr account = at(i);
if (account->profileName() == profileName) {
return account;
if (toReturn) return nullptr;
toReturn = account;
}
}
return nullptr;
return toReturn;
}

const MinecraftAccountPtr AccountList::at(int i) const
Expand Down Expand Up @@ -379,7 +381,7 @@ QVariant AccountList::headerData(int section, [[maybe_unused]] Qt::Orientation o
case NameColumn:
return tr("User name of the account.");
case TypeColumn:
return tr("Type of the account - Mojang or MSA.");
return tr("Type of the account - Ely.by or MSA.");
case StatusColumn:
return tr("Current status of the account.");
case MigrationColumn:
Expand Down Expand Up @@ -434,7 +436,7 @@ bool AccountList::setData(const QModelIndex& idx, const QVariant& value, int rol
bool AccountList::loadList()
{
if (m_listFilePath.isEmpty()) {
qCritical() << "Can't load Mojang account list. No file path given and no default set.";
qCritical() << "Can't load Ely.by account list. No file path given and no default set.";
return false;
}

Expand Down Expand Up @@ -550,7 +552,7 @@ bool AccountList::loadV3(QJsonObject& root)
bool AccountList::saveList()
{
if (m_listFilePath.isEmpty()) {
qCritical() << "Can't save Mojang account list. No file path given and no default set.";
qCritical() << "Can't save Ely.by account list. No file path given and no default set.";
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion launcher/minecraft/auth/MinecraftAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class MinecraftAccount : public QObject, public Usable {
if (data.legacy) {
return "legacy";
}
return "mojang";
return "ely.by";
} break;
case AccountType::MSA: {
return "msa";
Expand Down
6 changes: 3 additions & 3 deletions launcher/minecraft/auth/Yggdrasil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void Yggdrasil::refresh()
req.insert("requestUser", false);
QJsonDocument doc(req);

QUrl reqUrl("https://authserver.mojang.com/refresh");
QUrl reqUrl("https://authserver.ely.by/auth/refresh");
QByteArray requestData = doc.toJson();

sendRequest(reqUrl, requestData);
Expand Down Expand Up @@ -130,7 +130,7 @@ void Yggdrasil::login(QString password)

QJsonDocument doc(req);

QUrl reqUrl("https://authserver.mojang.com/authenticate");
QUrl reqUrl("https://authserver.ely.by/auth/authenticate");
QNetworkRequest netRequest(reqUrl);
QByteArray requestData = doc.toJson();

Expand Down Expand Up @@ -270,7 +270,7 @@ void Yggdrasil::processReply()
break;
case QNetworkReply::ContentGoneError: {
changeState(AccountTaskState::STATE_FAILED_GONE,
tr("The Mojang account no longer exists. It may have been migrated to a Microsoft account."));
tr("The Ely.by account no longer exists. It may have been migrated to a Microsoft account."));
return;
}
default:
Expand Down
44 changes: 26 additions & 18 deletions launcher/minecraft/auth/steps/MigrationEligibilityStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <QNetworkRequest>

#include "minecraft/auth/AuthRequest.h"
#include "Application.h"
#include "minecraft/auth/Parsers.h"

MigrationEligibilityStep::MigrationEligibilityStep(AccountData* data) : AuthStep(data) {}
Expand All @@ -16,30 +16,38 @@ QString MigrationEligibilityStep::describe()

void MigrationEligibilityStep::perform()
{
auto url = QUrl("https://api.minecraftservices.com/rollout/v1/msamigration");
QNetworkRequest request = QNetworkRequest(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8());

AuthRequest* requestor = new AuthRequest(this);
connect(requestor, &AuthRequest::finished, this, &MigrationEligibilityStep::onRequestDone);
requestor->get(request);
m_filesNetJob.reset(new NetJob(tr("Injector URL download"), APPLICATION->network()));

m_filesNetJob->addNetAction(Net::Download::makeByteArray(QUrl(injector_download_url), m_response));

connect(m_filesNetJob.get(), &NetJob::succeeded, this, &MigrationEligibilityStep::onUrlRequestDone);
connect(m_filesNetJob.get(), &NetJob::failed, this, &MigrationEligibilityStep::downloadFailed);

m_filesNetJob->start();
}

void MigrationEligibilityStep::rehydrate()
{
// NOOP, for now. We only save bools and there's nothing to check.
}

void MigrationEligibilityStep::onRequestDone(QNetworkReply::NetworkError error,
QByteArray data,
QList<QNetworkReply::RawHeaderPair> headers)
void MigrationEligibilityStep::onUrlRequestDone() {
m_filesNetJob.reset(new NetJob(tr("Injector download"), APPLICATION->network()));

m_filesNetJob->addNetAction(Net::Download::makeFile(QUrl(*m_response), "authlib-injector.jar"));

connect(m_filesNetJob.get(), &NetJob::succeeded, this, &MigrationEligibilityStep::onDownloadDone);
connect(m_filesNetJob.get(), &NetJob::failed, this, &MigrationEligibilityStep::downloadFailed);

m_filesNetJob->start();
}

void MigrationEligibilityStep::onDownloadDone()
{
auto requestor = qobject_cast<AuthRequest*>(QObject::sender());
requestor->deleteLater();
emit finished(AccountTaskState::STATE_WORKING, tr("Downloaded injector"));
}

if (error == QNetworkReply::NoError) {
Parsers::parseRolloutResponse(data, m_data->canMigrateToMSA);
}
emit finished(AccountTaskState::STATE_WORKING, tr("Got migration flags"));
void MigrationEligibilityStep::downloadFailed(QString reason)
{
emit finished(AccountTaskState::STATE_OFFLINE, tr("Injector download failed"));
}
11 changes: 10 additions & 1 deletion launcher/minecraft/auth/steps/MigrationEligibilityStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include "QObjectPtr.h"
#include "minecraft/auth/AuthStep.h"
#include "net/NetJob.h"
static const char* const injector_download_url =
"https://raw.githubusercontent.com/Octol1ttle/PrismLauncher-elyby/develop/injector-download.url";

class MigrationEligibilityStep : public AuthStep {
Q_OBJECT
Expand All @@ -16,6 +19,12 @@ class MigrationEligibilityStep : public AuthStep {

QString describe() override;

private:
NetJob::Ptr m_filesNetJob;
std::shared_ptr<QByteArray> m_response = std::make_shared<QByteArray>();

private slots:
void onRequestDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
void onUrlRequestDone();
void onDownloadDone();
void downloadFailed(QString reason);
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void MinecraftProfileStepMojang::perform()
}

// use session server instead of profile due to profile endpoint being locked for locked Mojang accounts
QUrl url = QUrl("https://sessionserver.mojang.com/session/minecraft/profile/" + m_data->minecraftProfile.id);
QUrl url = QUrl("https://account.ely.by/api/minecraft/session/profile/" + m_data->minecraftProfile.id);
QNetworkRequest req = QNetworkRequest(url);
AuthRequest* request = new AuthRequest(this);
connect(request, &AuthRequest::finished, this, &MinecraftProfileStepMojang::onRequestDone);
Expand Down
8 changes: 4 additions & 4 deletions launcher/minecraft/auth/steps/YggdrasilStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ YggdrasilStep::~YggdrasilStep() noexcept = default;

QString YggdrasilStep::describe()
{
return tr("Logging in with Mojang account.");
return tr("Logging in with Ely.by account.");
}

void YggdrasilStep::rehydrate()
Expand All @@ -36,7 +36,7 @@ void YggdrasilStep::perform()

void YggdrasilStep::onAuthSucceeded()
{
emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Mojang"));
emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Ely.by"));
}

void YggdrasilStep::onAuthFailed()
Expand All @@ -46,12 +46,12 @@ void YggdrasilStep::onAuthFailed()
// m_aborted = m_yggdrasil->m_aborted;

auto state = m_yggdrasil->taskState();
QString errorMessage = tr("Mojang user authentication failed.");
QString errorMessage = tr("Ely.by user authentication failed.");

// 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.");
errorMessage = tr("Ely.by user authentication ended with a network error.");
}
emit finished(state, errorMessage);
}
2 changes: 1 addition & 1 deletion launcher/minecraft/launch/ClaimAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ClaimAccount::ClaimAccount(LaunchTask* parent, AuthSessionPtr session) : LaunchS
{
if (session->status == AuthSession::Status::PlayableOnline && !session->demo) {
auto accounts = APPLICATION->accounts();
m_account = accounts->getAccountByProfileName(session->player_name);
m_account = accounts->at(accounts->findAccountByProfileId(session->uuid));
}
}

Expand Down
Loading

0 comments on commit f2b3ce2

Please sign in to comment.