MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / ModrinthAPI

Class ModrinthAPI

launcher/modplatform/modrinth/ModrinthAPI.h:13–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <QDebug>
12
13class ModrinthAPI : public NetworkResourceAPI {
14 public:
15 auto currentVersion(QString hash, QString hash_format, std::shared_ptr<QByteArray> response) -> Task::Ptr;
16
17 auto currentVersions(const QStringList& hashes, QString hash_format, std::shared_ptr<QByteArray> response) -> Task::Ptr;
18
19 auto latestVersion(QString hash,
20 QString hash_format,
21 std::optional<std::list<Version>> mcVersions,
22 std::optional<ModPlatform::ModLoaderTypes> loaders,
23 std::shared_ptr<QByteArray> response) -> Task::Ptr;
24
25 auto latestVersions(const QStringList& hashes,
26 QString hash_format,
27 std::optional<std::list<Version>> mcVersions,
28 std::optional<ModPlatform::ModLoaderTypes> loaders,
29 std::shared_ptr<QByteArray> response) -> Task::Ptr;
30
31 Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const override;
32
33 static Task::Ptr getModCategories(std::shared_ptr<QByteArray> response);
34 static QList<ModPlatform::Category> loadCategories(std::shared_ptr<QByteArray> response, QString projectType);
35 static QList<ModPlatform::Category> loadModCategories(std::shared_ptr<QByteArray> response);
36
37 public:
38 [[nodiscard]] auto getSortingMethods() const -> QList<ResourceAPI::SortingMethod> override;
39
40 inline auto getAuthorURL(const QString& name) const -> QString { return "https://modrinth.com/user/" + name; };
41
42 static auto getModLoaderStrings(const ModPlatform::ModLoaderTypes types) -> const QStringList
43 {
44 QStringList l;
45 for (auto loader :
46 { ModPlatform::NeoForge, ModPlatform::Forge, ModPlatform::Fabric, ModPlatform::Quilt, ModPlatform::LiteLoader }) {
47 if (types & loader) {
48 l << getModLoaderAsString(loader);
49 }
50 }
51 return l;
52 }
53
54 static auto getModLoaderFilters(ModPlatform::ModLoaderTypes types) -> const QString
55 {
56 QStringList l;
57 for (auto loader : getModLoaderStrings(types)) {
58 l << QString("\"categories:%1\"").arg(loader);
59 }
60 return l.join(',');
61 }
62
63 static auto getCategoriesFilters(QStringList categories) -> const QString
64 {
65 QStringList l;
66 for (auto cat : categories) {
67 l << QString("\"categories:%1\"").arg(cat);
68 }
69 return l.join(',');
70 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected