aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform/modrinth/ModrinthAPI.h
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/modplatform/modrinth/ModrinthAPI.h')
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h
index 4ae8b8f9..44a362c8 100644
--- a/launcher/modplatform/modrinth/ModrinthAPI.h
+++ b/launcher/modplatform/modrinth/ModrinthAPI.h
@@ -2,17 +2,24 @@
#include "modplatform/ModAPI.h"
+#include <QDebug>
+
class ModrinthAPI : public ModAPI {
public:
- inline QString getModSearchURL(int offset, QString query, QString sort, bool fabricCompatible, QString version) const override
+ inline QString getModSearchURL(int offset, QString query, QString sort, ModLoaderType modLoader, QString version) const override
{
+ if(!validateModLoader(modLoader)){
+ qWarning() << "Modrinth only have Forge and Fabric-compatible mods!";
+ return "";
+ }
+
return QString("https://api.modrinth.com/v2/search?"
"offset=%1&" "limit=25&" "query=%2&" "index=%3&"
"facets=[[\"categories:%4\"],[\"versions:%5\"],[\"project_type:mod\"]]")
.arg(offset)
.arg(query)
.arg(sort)
- .arg(fabricCompatible ? "fabric" : "forge")
+ .arg(getModLoaderString(modLoader))
.arg(version);
};
@@ -22,4 +29,22 @@ class ModrinthAPI : public ModAPI {
};
inline QString getAuthorURL(const QString& name) const override { return "https://modrinth.com/user/" + name; };
+
+ private:
+ inline bool validateModLoader(ModLoaderType modLoader) const{
+ return modLoader == Any || modLoader == Forge || modLoader == Fabric;
+ }
+
+ inline QString getModLoaderString(ModLoaderType modLoader) const{
+ switch(modLoader){
+ case Any:
+ return "fabric, forge";
+ case Forge:
+ return "forge";
+ case Fabric:
+ return "fabric";
+ default:
+ return "";
+ }
+ }
};