2022-03-03 07:31:23 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "modplatform/ModAPI.h"
|
|
|
|
|
2022-03-07 01:15:39 +05:30
|
|
|
#include <QDebug>
|
|
|
|
|
2022-03-03 07:31:23 +05:30
|
|
|
class ModrinthAPI : public ModAPI {
|
|
|
|
public:
|
2022-03-07 01:15:39 +05:30
|
|
|
inline QString getModSearchURL(int offset, QString query, QString sort, ModLoaderType modLoader, QString version) const override
|
2022-03-03 07:31:23 +05:30
|
|
|
{
|
2022-03-07 01:15:39 +05:30
|
|
|
if(!validateModLoader(modLoader)){
|
|
|
|
qWarning() << "Modrinth only have Forge and Fabric-compatible mods!";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2022-03-03 07:31:23 +05:30
|
|
|
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)
|
2022-03-07 01:15:39 +05:30
|
|
|
.arg(getModLoaderString(modLoader))
|
2022-03-03 07:31:23 +05:30
|
|
|
.arg(version);
|
|
|
|
};
|
|
|
|
|
|
|
|
inline QString getVersionsURL(const QString& addonId) const override
|
|
|
|
{
|
|
|
|
return QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId);
|
|
|
|
};
|
|
|
|
|
|
|
|
inline QString getAuthorURL(const QString& name) const override { return "https://modrinth.com/user/" + name; };
|
2022-03-07 01:15:39 +05:30
|
|
|
|
|
|
|
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 "";
|
|
|
|
}
|
|
|
|
}
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|