This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from RPMTW/fix/modrinth
fix: download mods on Modrinth
- Loading branch information
Showing
23 changed files
with
208 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
String mojangMetaAPI = 'https://launchermeta.mojang.com/mc/game'; | ||
String fabricApi = 'https://meta.fabricmc.net/v2'; | ||
String forgeFilesAPI = 'https://files.minecraftforge.net'; | ||
String forgeFilesMainAPI = | ||
'https://files.minecraftforge.net/net/minecraftforge/forge'; | ||
String forgeLatestVersionAPI = '$forgeFilesMainAPI/promotions_slim.json'; | ||
String forgeMavenUrl = 'https://maven.minecraftforge.net'; | ||
String forgeMavenMainUrl = | ||
'https://maven.minecraftforge.net/net/minecraftforge/forge'; | ||
String mojangJavaRuntimeAPI = | ||
'https://launchermeta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json'; | ||
String mojangAuthAPI = 'https://authserver.mojang.com'; | ||
String microsoftProfileAPI = | ||
'https://api.minecraftservices.com/minecraft/profile'; | ||
String modrinthAPI = 'https://api.modrinth.com/v2'; | ||
String ftbModPackAPI = 'https://api.modpacks.ch/public'; | ||
String minecraftNewsRSS = | ||
'https://www.minecraft.net/en-us/feeds/community-content/rss'; | ||
String recommendedModpack = | ||
'https://github.com/RPMTW/RPMTW-website-data/raw/main/data/RPMLauncher/recommend-modpack.json'; | ||
String paperApi = 'https://papermc.io/api/v2'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:rpmlauncher/launcher/apis.dart'; | ||
import 'package:rpmlauncher/util/I18n.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:rpmlauncher/util/RPMHttpClient.dart'; | ||
|
||
class ModrinthHandler { | ||
static Future<List<dynamic>> getModList(String versionID, String loader, | ||
TextEditingController search, List beforeModList, int index, sort) async { | ||
String searchFilter = ''; | ||
if (search.text.isNotEmpty) { | ||
searchFilter = '&query=${search.text}'; | ||
} | ||
List modList = beforeModList; | ||
Response response = await RPMHttpClient().get( | ||
'$modrinthAPI/search?facets=[["versions:$versionID"],["categories:$loader"],["project_type:mod"]]$searchFilter&offset=${20 * index}&limit=20&index=$sort'); | ||
Map body = RPMHttpClient.json(response); | ||
modList.addAll(body['hits']); | ||
return modList; | ||
} | ||
|
||
static Future<List<dynamic>> getModFilesInfo( | ||
modrinthID, versionID, loader) async { | ||
Response response = | ||
await RPMHttpClient().get('$modrinthAPI/project/$modrinthID/version'); | ||
late List<dynamic> filesInfo = []; | ||
|
||
List<Map> modVersions = RPMHttpClient.json(response).cast<Map>(); | ||
modVersions.forEach((versions) { | ||
if (versions['game_versions'].any((element) => element == versionID) && | ||
versions['loaders'].any((element) => element == loader)) { | ||
filesInfo.add(versions); | ||
} | ||
}); | ||
return filesInfo; | ||
} | ||
|
||
static Text parseReleaseType(String releaseType) { | ||
late Text releaseTypeString; | ||
if (releaseType == 'release') { | ||
releaseTypeString = Text(I18n.format('edit.instance.mods.release'), | ||
style: const TextStyle(color: Colors.lightGreen)); | ||
} else if (releaseType == 'beta') { | ||
releaseTypeString = Text(I18n.format('edit.instance.mods.beta'), | ||
style: const TextStyle(color: Colors.lightBlue)); | ||
} else if (releaseType == 'alpha') { | ||
releaseTypeString = Text(I18n.format('edit.instance.mods.alpha'), | ||
style: const TextStyle(color: Colors.red)); | ||
} | ||
return releaseTypeString; | ||
} | ||
|
||
static Text parseSide(String sideString, String side, Map data) { | ||
Text parse(sideName, type) { | ||
late final Text sideText; | ||
if (type == 'required') { | ||
sideText = Text( | ||
sideName + I18n.format('edit.instance.mods.side.required'), | ||
style: const TextStyle(color: Colors.red), | ||
); | ||
} else if (type == 'optional') { | ||
sideText = Text( | ||
sideName + I18n.format('edit.instance.mods.side.optional'), | ||
style: const TextStyle(color: Colors.lightGreenAccent), | ||
); | ||
} else if (type == 'unsupported') { | ||
sideText = Text( | ||
sideName + I18n.format('edit.instance.mods.side.unsupported'), | ||
style: const TextStyle(color: Colors.grey), | ||
); | ||
} | ||
|
||
return sideText; | ||
} | ||
|
||
return parse(sideString, data[side]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.