feat: add ability to change assets download server
Signed-off-by: clague <93119153+clague@users.noreply.github.com>
This commit is contained in:
parent
2c91629564
commit
4bf6e59f3b
6 changed files with 73 additions and 3 deletions
|
@ -166,7 +166,7 @@ class Config {
|
||||||
QString DISCORD_URL;
|
QString DISCORD_URL;
|
||||||
QString SUBREDDIT_URL;
|
QString SUBREDDIT_URL;
|
||||||
|
|
||||||
QString RESOURCE_BASE = "https://resources.download.minecraft.net/";
|
QString DEFAULT_RESOURCE_BASE = "https://resources.download.minecraft.net/";
|
||||||
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
|
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
|
||||||
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
|
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
|
||||||
QString FMLLIBS_BASE_URL;
|
QString FMLLIBS_BASE_URL;
|
||||||
|
|
|
@ -864,6 +864,15 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
// get rid of invalid meta urls
|
// get rid of invalid meta urls
|
||||||
if (!metaUrl.isValid() || (metaUrl.scheme() != "http" && metaUrl.scheme() != "https"))
|
if (!metaUrl.isValid() || (metaUrl.scheme() != "http" && metaUrl.scheme() != "https"))
|
||||||
m_settings->reset("MetaURLOverride");
|
m_settings->reset("MetaURLOverride");
|
||||||
|
|
||||||
|
// Resource URL
|
||||||
|
m_settings->registerSetting("ResourceURLOverride", "");
|
||||||
|
|
||||||
|
QUrl resourceUrl(m_settings->get("ResourceURLOverride").toString());
|
||||||
|
|
||||||
|
// get rid of invalid resource urls
|
||||||
|
if (!resourceUrl.isValid() || (resourceUrl.scheme() != "http" && resourceUrl.scheme() != "https"))
|
||||||
|
m_settings->reset("ResourceURLOverride");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings->registerSetting("CloseAfterLaunch", false);
|
m_settings->registerSetting("CloseAfterLaunch", false);
|
||||||
|
|
|
@ -298,7 +298,12 @@ QString AssetObject::getLocalPath()
|
||||||
|
|
||||||
QUrl AssetObject::getUrl()
|
QUrl AssetObject::getUrl()
|
||||||
{
|
{
|
||||||
return BuildConfig.RESOURCE_BASE + getRelPath();
|
auto s = APPLICATION->settings();
|
||||||
|
auto resourceURL = s->get("ResourceURLOverride").toString();
|
||||||
|
if (resourceURL.isEmpty()) {
|
||||||
|
return BuildConfig.DEFAULT_RESOURCE_BASE + getRelPath();
|
||||||
|
}
|
||||||
|
return resourceURL + getRelPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AssetObject::getRelPath()
|
QString AssetObject::getRelPath()
|
||||||
|
|
|
@ -71,7 +71,15 @@ void AssetUpdateTask::assetIndexFinished()
|
||||||
|
|
||||||
auto job = index.getDownloadJob();
|
auto job = index.getDownloadJob();
|
||||||
if (job) {
|
if (job) {
|
||||||
setStatus(tr("Getting the assets files from Mojang..."));
|
QString resourceURLRaw;
|
||||||
|
auto statusText = tr("Getting the assets files from Mojang...");
|
||||||
|
resourceURLRaw = APPLICATION->settings()->get("ResourceURLOverride").toString();
|
||||||
|
// FIXME: Need translation
|
||||||
|
if (!resourceURLRaw.isEmpty()) {
|
||||||
|
QUrl resourceURL = QUrl(resourceURLRaw);
|
||||||
|
statusText.replace("Mojang", resourceURL.host());
|
||||||
|
}
|
||||||
|
setStatus(statusText);
|
||||||
downloadJob = job;
|
downloadJob = job;
|
||||||
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
|
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
|
||||||
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
|
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
|
||||||
|
|
|
@ -76,6 +76,7 @@ APIPage::APIPage(QWidget* parent) : QWidget(parent), ui(new Ui::APIPage)
|
||||||
updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex());
|
updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex());
|
||||||
// NOTE: this allows http://, but we replace that with https later anyway
|
// NOTE: this allows http://, but we replace that with https later anyway
|
||||||
ui->metaURL->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->metaURL));
|
ui->metaURL->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->metaURL));
|
||||||
|
ui->resourceURL->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->resourceURL));
|
||||||
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->baseURLEntry));
|
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->baseURLEntry));
|
||||||
ui->msaClientID->setValidator(new QRegularExpressionValidator(s_validMSAClientID, ui->msaClientID));
|
ui->msaClientID->setValidator(new QRegularExpressionValidator(s_validMSAClientID, ui->msaClientID));
|
||||||
ui->flameKey->setValidator(new QRegularExpressionValidator(s_validFlameKey, ui->flameKey));
|
ui->flameKey->setValidator(new QRegularExpressionValidator(s_validFlameKey, ui->flameKey));
|
||||||
|
@ -137,6 +138,8 @@ void APIPage::loadSettings()
|
||||||
ui->msaClientID->setText(msaClientID);
|
ui->msaClientID->setText(msaClientID);
|
||||||
QString metaURL = s->get("MetaURLOverride").toString();
|
QString metaURL = s->get("MetaURLOverride").toString();
|
||||||
ui->metaURL->setText(metaURL);
|
ui->metaURL->setText(metaURL);
|
||||||
|
QString resourceURL = s->get("ResourceURLOverride").toString();
|
||||||
|
ui->resourceURL->setText(resourceURL);
|
||||||
QString flameKey = s->get("FlameKeyOverride").toString();
|
QString flameKey = s->get("FlameKeyOverride").toString();
|
||||||
ui->flameKey->setText(flameKey);
|
ui->flameKey->setText(flameKey);
|
||||||
QString modrinthToken = s->get("ModrinthToken").toString();
|
QString modrinthToken = s->get("ModrinthToken").toString();
|
||||||
|
@ -156,18 +159,31 @@ void APIPage::applySettings()
|
||||||
QString msaClientID = ui->msaClientID->text();
|
QString msaClientID = ui->msaClientID->text();
|
||||||
s->set("MSAClientIDOverride", msaClientID);
|
s->set("MSAClientIDOverride", msaClientID);
|
||||||
QUrl metaURL(ui->metaURL->text());
|
QUrl metaURL(ui->metaURL->text());
|
||||||
|
QUrl resourceURL(ui->resourceURL->text());
|
||||||
// Add required trailing slash
|
// Add required trailing slash
|
||||||
if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) {
|
if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) {
|
||||||
QString path = metaURL.path();
|
QString path = metaURL.path();
|
||||||
path.append('/');
|
path.append('/');
|
||||||
metaURL.setPath(path);
|
metaURL.setPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!resourceURL.isEmpty() && !resourceURL.path().endsWith('/')) {
|
||||||
|
QString path = resourceURL.path();
|
||||||
|
path.append('/');
|
||||||
|
resourceURL.setPath(path);
|
||||||
|
}
|
||||||
// Don't allow HTTP, since meta is basically RCE with all the jar files.
|
// Don't allow HTTP, since meta is basically RCE with all the jar files.
|
||||||
if (!metaURL.isEmpty() && metaURL.scheme() == "http") {
|
if (!metaURL.isEmpty() && metaURL.scheme() == "http") {
|
||||||
metaURL.setScheme("https");
|
metaURL.setScheme("https");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also don't allow HTTP
|
||||||
|
if (!resourceURL.isEmpty() && resourceURL.scheme() == "http") {
|
||||||
|
resourceURL.setScheme("https");
|
||||||
|
}
|
||||||
|
|
||||||
s->set("MetaURLOverride", metaURL.toString());
|
s->set("MetaURLOverride", metaURL.toString());
|
||||||
|
s->set("ResourceURLOverride", resourceURL.toString());
|
||||||
QString flameKey = ui->flameKey->text();
|
QString flameKey = ui->flameKey->text();
|
||||||
s->set("FlameKeyOverride", flameKey);
|
s->set("FlameKeyOverride", flameKey);
|
||||||
QString modrinthToken = ui->modrinthToken->text();
|
QString modrinthToken = ui->modrinthToken->text();
|
||||||
|
|
|
@ -129,6 +129,38 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_assets">
|
||||||
|
<property name="title">
|
||||||
|
<string>Assets Server</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>You can set this to another server if you have problem in downloading assets.</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::RichText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="resourceURL">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Use Default</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_ua">
|
<widget class="QGroupBox" name="groupBox_ua">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue