diff --git a/CMakeLists.txt b/CMakeLists.txt index 435959db4..3029f087f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,12 @@ set(Launcher_DISCORD_URL "https://prismlauncher.org/discord" CACHE STRING "URL f # Subreddit URL set(Launcher_SUBREDDIT_URL "https://prismlauncher.org/reddit" CACHE STRING "URL for the subreddit.") +# Minecraft Resources URL +set(Launcher_RESOURCE_BASE "https://resources.download.minecraft.net/" CACHE STRING "URL for the Minecraft resources.") + +# Minecraft Libraries URL +set(Launcher_LIBRARY_BASE "https://libraries.minecraft.net/" CACHE STRING "URL for the Minecraft Libraries.") + # Builds set(Launcher_FORCE_BUNDLED_LIBS OFF CACHE BOOL "Prevent using system libraries, if they are available as submodules") set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build against") diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index 61dce359c..121ac5ad5 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -119,6 +119,9 @@ Config::Config() DISCORD_URL = "@Launcher_DISCORD_URL@"; SUBREDDIT_URL = "@Launcher_SUBREDDIT_URL@"; + RESOURCE_BASE = "@Launcher_RESOURCE_BASE@"; + LIBRARY_BASE = "@Launcher_LIBRARY_BASE@"; + FMLLIBS_BASE_URL = "@Launcher_FMLLIBS_BASE_URL@"; TRANSLATIONS_BASE_URL = "@Launcher_TRANSLATIONS_BASE_URL@"; } diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h index dc1336986..434d50b0f 100644 --- a/buildconfig/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -143,8 +143,8 @@ class Config { QString DISCORD_URL; QString SUBREDDIT_URL; - QString RESOURCE_BASE = "https://resources.download.minecraft.net/"; - QString LIBRARY_BASE = "https://libraries.minecraft.net/"; + QString RESOURCE_BASE; + QString LIBRARY_BASE; QString AUTH_BASE = "https://authserver.mojang.com/"; QString IMGUR_BASE_URL = "https://api.imgur.com/3/"; QString FMLLIBS_BASE_URL; diff --git a/launcher/Application.cpp b/launcher/Application.cpp index fa8ea8dfa..9543c8089 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -676,6 +676,21 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) if (!metaUrl.isValid() || (metaUrl.scheme() != "http" && metaUrl.scheme() != "https")) m_settings->reset("MetaURLOverride"); } + // Some custom urls from Mojang + { + // Resource Base Url + m_settings->registerSetting("MinecraftResourceURLOverride", ""); + // Libraries Base Url + m_settings->registerSetting("MinecraftLibrariesURLOverride", ""); + + QUrl resourceUrl(m_settings->get("MinecraftResourceURLOverride").toString()); + QUrl librariesUrl(m_settings->get("MinecraftLibrariesURLOverride").toString()); + + if (!resourceUrl.isValid() || (resourceUrl.scheme() != "http" && resourceUrl.scheme() != "https")) + m_settings->reset("MinecraftResourceURLOverride"); + if (!librariesUrl.isValid() || (librariesUrl.scheme() != "http" && resourceUrl.scheme() != "https")) + m_settings->reset("MinecraftLibrariesURLOverride"); + } m_settings->registerSetting("CloseAfterLaunch", false); m_settings->registerSetting("QuitAfterGameStop", false); diff --git a/launcher/minecraft/AssetsUtils.cpp b/launcher/minecraft/AssetsUtils.cpp index 4ef007075..9dab28e1e 100644 --- a/launcher/minecraft/AssetsUtils.cpp +++ b/launcher/minecraft/AssetsUtils.cpp @@ -297,7 +297,12 @@ QString AssetObject::getLocalPath() QUrl AssetObject::getUrl() { - return BuildConfig.RESOURCE_BASE + getRelPath(); + QString resourceOverride = APPLICATION->settings()->get("MinecraftResourceURLOverride").toString(); + if (resourceOverride.isEmpty()) { + return BuildConfig.RESOURCE_BASE + getRelPath(); + } else { + return resourceOverride + getRelPath(); + } } QString AssetObject::getRelPath() diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp index 0e8ddf03d..ae57d69d3 100644 --- a/launcher/minecraft/Library.cpp +++ b/launcher/minecraft/Library.cpp @@ -172,7 +172,12 @@ QList Library::getDownloads(const RuntimeContext& runtimeContext } if (m_repositoryURL.isEmpty()) { - return BuildConfig.LIBRARY_BASE + raw_storage; + QString librariesOverride = APPLICATION->settings()->get("MinecraftLibrariesURLOverride").toString(); + if (librariesOverride.isEmpty()) { + return BuildConfig.LIBRARY_BASE + raw_storage; + } else { + return librariesOverride + raw_storage; + } } if (m_repositoryURL.endsWith('/')) { diff --git a/launcher/ui/pages/global/APIPage.cpp b/launcher/ui/pages/global/APIPage.cpp index 82aa76a4f..b87e3c76b 100644 --- a/launcher/ui/pages/global/APIPage.cpp +++ b/launcher/ui/pages/global/APIPage.cpp @@ -76,11 +76,15 @@ APIPage::APIPage(QWidget* parent) : QWidget(parent), ui(new Ui::APIPage) updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex()); // NOTE: this allows http://, but we replace that with https later anyway ui->metaURL->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->metaURL)); + ui->resourceURL->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->resourceURL)); + ui->librariesURL->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->librariesURL)); ui->baseURLEntry->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->baseURLEntry)); ui->msaClientID->setValidator(new QRegularExpressionValidator(validMSAClientID, ui->msaClientID)); ui->flameKey->setValidator(new QRegularExpressionValidator(validFlameKey, ui->flameKey)); ui->metaURL->setPlaceholderText(BuildConfig.META_URL); + ui->resourceURL->setPlaceholderText(BuildConfig.RESOURCE_BASE); + ui->librariesURL->setPlaceholderText(BuildConfig.LIBRARY_BASE); ui->userAgentLineEdit->setPlaceholderText(BuildConfig.USER_AGENT); loadSettings(); @@ -137,6 +141,10 @@ void APIPage::loadSettings() ui->msaClientID->setText(msaClientID); QString metaURL = s->get("MetaURLOverride").toString(); ui->metaURL->setText(metaURL); + QString resourceURL = s->get("MinecraftResourceURLOverride").toString(); + ui->resourceURL->setText(resourceURL); + QString librariesURL = s->get("MinecraftLibrariesURLOverride").toString(); + ui->librariesURL->setText(librariesURL); QString flameKey = s->get("FlameKeyOverride").toString(); ui->flameKey->setText(flameKey); QString modrinthToken = s->get("ModrinthToken").toString(); @@ -165,8 +173,34 @@ void APIPage::applySettings() if (!metaURL.isEmpty() && metaURL.scheme() == "http") { metaURL.setScheme("https"); } - s->set("MetaURLOverride", metaURL.toString()); + + QUrl resourceURL(ui->resourceURL->text()); + // Add required trailing slash + if (!resourceURL.isEmpty() && !resourceURL.path().endsWith('/')) { + QString path = resourceURL.path(); + path.append('/'); + resourceURL.setPath(path); + } + // HTTP may not be allowed either? + if (!resourceURL.isEmpty() && resourceURL.scheme() == "http") { + resourceURL.setScheme("https"); + } + s->set("MinecraftResourceURLOverride", resourceURL.toString()); + + QUrl librariesURL(ui->librariesURL->text()); + // Add required trailing slash + if (!librariesURL.isEmpty() && !librariesURL.path().endsWith('/')) { + QString path = librariesURL.path(); + path.append('/'); + librariesURL.setPath(path); + } + // HTTP may not be allowed either? + if (!librariesURL.isEmpty() && librariesURL.scheme() == "http") { + librariesURL.setScheme("https"); + } + s->set("MinecraftLibrariesURLOverride", librariesURL.toString()); + QString flameKey = ui->flameKey->text(); s->set("FlameKeyOverride", flameKey); QString modrinthToken = ui->modrinthToken->text(); diff --git a/launcher/ui/pages/global/APIPage.ui b/launcher/ui/pages/global/APIPage.ui index 492741ba4..42462369f 100644 --- a/launcher/ui/pages/global/APIPage.ui +++ b/launcher/ui/pages/global/APIPage.ui @@ -130,6 +130,42 @@ + + + + Minecraft Resource Server + + + + + + When certain urls in Minecraft change, you can set new urls here. + + + Qt::RichText + + + true + + + + + + + + + + + + + + + + + + + +