aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-04-21 15:45:20 -0300
committerflow <flowlnlnln@gmail.com>2022-05-23 14:43:09 -0300
commite17b6804a7424dd5161662c4ef92972f3311675c (patch)
tree2d6e5268d3ce2499d6e765797c35a4bec7062aa3
parent96e36f060443cbfa6d58df2adca3c8605851b4a3 (diff)
downloadPrismLauncher-e17b6804a7424dd5161662c4ef92972f3311675c.tar.gz
PrismLauncher-e17b6804a7424dd5161662c4ef92972f3311675c.tar.bz2
PrismLauncher-e17b6804a7424dd5161662c4ef92972f3311675c.zip
fix: implement PR suggestions
Some stylistic changes, and get hashes from the mod providers when building the metadata.
-rw-r--r--launcher/Application.cpp2
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp11
-rw-r--r--launcher/modplatform/ModIndex.h3
-rw-r--r--launcher/modplatform/flame/FlameModIndex.cpp8
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp4
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp2
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp2
7 files changed, 20 insertions, 12 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index ae4cbcf8..99e3d4c5 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -644,7 +644,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_settings->registerSetting("MCLaunchMethod", "LauncherPart");
// Minecraft mods
- m_settings->registerSetting("DontUseModMetadata", false);
+ m_settings->registerSetting("ModMetadataDisabled", false);
// Minecraft offline player name
m_settings->registerSetting("LastOfflinePlayerName", "");
diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
index addb0dd8..fe807a29 100644
--- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
+++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
@@ -10,7 +10,7 @@ ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
void ModFolderLoadTask::run()
{
- if (!APPLICATION->settings()->get("DontUseModMetadata").toBool()) {
+ if (!APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
// Read metadata first
getFromMetadata();
}
@@ -34,14 +34,9 @@ void ModFolderLoadTask::run()
void ModFolderLoadTask::getFromMetadata()
{
m_index_dir.refresh();
- for (auto entry : m_index_dir.entryList()) {
- // QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
- if (entry == "." || entry == "..")
- continue;
-
+ for (auto entry : m_index_dir.entryList(QDir::Files)) {
auto metadata = Metadata::get(m_index_dir, entry);
- // TODO: Don't simply return. Instead, show to the user that the metadata is there, but
- // it's not currently 'installed' (i.e. there's no JAR file yet).
+
if(!metadata.isValid()){
return;
}
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index bb5c7c9d..2137f616 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -8,7 +8,7 @@
namespace ModPlatform {
-enum class Provider{
+enum class Provider {
MODRINTH,
FLAME
};
@@ -33,6 +33,7 @@ struct IndexedVersion {
QString date;
QString fileName;
QVector<QString> loaders = {};
+ QString hash;
};
struct IndexedPack {
diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp
index 45f02b71..4b172c13 100644
--- a/launcher/modplatform/flame/FlameModIndex.cpp
+++ b/launcher/modplatform/flame/FlameModIndex.cpp
@@ -6,6 +6,8 @@
#include "modplatform/flame/FlameAPI.h"
#include "net/NetJob.h"
+static ModPlatform::ProviderCapabilities ProviderCaps;
+
void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
{
pack.addonId = Json::requireInteger(obj, "id");
@@ -60,6 +62,12 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
file.downloadUrl = Json::requireString(obj, "downloadUrl");
file.fileName = Json::requireString(obj, "fileName");
+ auto hash_list = Json::ensureArray(obj, "hashes");
+ if(!hash_list.isEmpty()){
+ if(hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::FLAME)))
+ file.hash = Json::requireString(hash_list, "value");
+ }
+
unsortedVersions.append(file);
}
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
index 6c8659dc..8b750740 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
@@ -24,6 +24,7 @@
#include "net/NetJob.h"
static ModrinthAPI api;
+static ModPlatform::ProviderCapabilities ProviderCaps;
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
{
@@ -95,6 +96,9 @@ void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
if (parent.contains("url")) {
file.downloadUrl = Json::requireString(parent, "url");
file.fileName = Json::requireString(parent, "filename");
+ auto hash_list = Json::requireObject(parent, "hashes");
+ if(hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::MODRINTH)))
+ file.hash = Json::requireString(hash_list, ProviderCaps.hashType(ModPlatform::Provider::MODRINTH));
unsortedVersions.append(file);
}
diff --git a/launcher/modplatform/packwiz/Packwiz.cpp b/launcher/modplatform/packwiz/Packwiz.cpp
index 50f87c24..70efc6bd 100644
--- a/launcher/modplatform/packwiz/Packwiz.cpp
+++ b/launcher/modplatform/packwiz/Packwiz.cpp
@@ -30,7 +30,7 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
mod.url = mod_version.downloadUrl;
mod.hash_format = ProviderCaps.hashType(mod_pack.provider);
- mod.hash = ""; // FIXME
+ mod.hash = mod_version.hash;
mod.provider = mod_pack.provider;
mod.file_id = mod_pack.addonId;
diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp
index 8754c0ec..faf9272d 100644
--- a/launcher/ui/pages/global/LauncherPage.cpp
+++ b/launcher/ui/pages/global/LauncherPage.cpp
@@ -345,7 +345,7 @@ void LauncherPage::applySettings()
}
// Mods
- s->set("DontUseModMetadata", ui->metadataDisableBtn->isChecked());
+ s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked());
}
void LauncherPage::loadSettings()
{