Add ability to change assets download server (#3875)

This commit is contained in:
timoreo 2025-07-18 09:14:45 +02:00 committed by GitHub
commit d63dba43d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 67 additions and 3 deletions

View file

@ -76,6 +76,7 @@ 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(s_validUrlRegExp, ui->metaURL));
ui->resourceURL->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->resourceURL));
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(s_validUrlRegExp, ui->baseURLEntry));
ui->msaClientID->setValidator(new QRegularExpressionValidator(s_validMSAClientID, ui->msaClientID));
ui->flameKey->setValidator(new QRegularExpressionValidator(s_validFlameKey, ui->flameKey));
@ -137,6 +138,8 @@ void APIPage::loadSettings()
ui->msaClientID->setText(msaClientID);
QString metaURL = s->get("MetaURLOverride").toString();
ui->metaURL->setText(metaURL);
QString resourceURL = s->get("ResourceURL").toString();
ui->resourceURL->setText(resourceURL);
QString flameKey = s->get("FlameKeyOverride").toString();
ui->flameKey->setText(flameKey);
QString modrinthToken = s->get("ModrinthToken").toString();
@ -156,18 +159,31 @@ void APIPage::applySettings()
QString msaClientID = ui->msaClientID->text();
s->set("MSAClientIDOverride", msaClientID);
QUrl metaURL(ui->metaURL->text());
QUrl resourceURL(ui->resourceURL->text());
// Add required trailing slash
if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) {
QString path = metaURL.path();
path.append('/');
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.
if (!metaURL.isEmpty() && metaURL.scheme() == "http") {
metaURL.setScheme("https");
}
// Also don't allow HTTP
if (!resourceURL.isEmpty() && resourceURL.scheme() == "http") {
resourceURL.setScheme("https");
}
s->set("MetaURLOverride", metaURL.toString());
s->set("ResourceURL", resourceURL.toString());
QString flameKey = ui->flameKey->text();
s->set("FlameKeyOverride", flameKey);
QString modrinthToken = ui->modrinthToken->text();

View file

@ -129,6 +129,38 @@
</layout>
</widget>
</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 problems with 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>
<widget class="QGroupBox" name="groupBox_ua">
<property name="minimumSize">