add overwrite of some mojang urls
Signed-off-by: wohaopa <2411829240@qq.com>
This commit is contained in:
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -172,7 +172,12 @@ QList<NetAction::Ptr> 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('/')) {
|
||||
|
@ -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();
|
||||
|
@ -130,6 +130,42 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_minecraft">
|
||||
<property name="title">
|
||||
<string>Minecraft Resource Server</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>When certain urls in Minecraft change, you can set new urls here.</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="resourceURL">
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="librariesURL">
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
Reference in New Issue
Block a user