1
0

Legacy Forge Support

This commit is contained in:
Jai A
2021-10-17 23:22:23 -07:00
parent 32850f6770
commit 16af479b83
9 changed files with 79 additions and 13 deletions

21
daedalus/src/forge.rs Normal file
View File

@@ -0,0 +1,21 @@
use crate::{download_file, Error};
use std::collections::HashMap;
/// The latest version of the format the model structs deserialize to
pub const CURRENT_FORMAT_VERSION: usize = 0;
const DEFAULT_MAVEN_METADATA_URL: &str =
"https://files.minecraftforge.net/net/minecraftforge/forge/maven-metadata.json";
/// Fetches the forge maven metadata from the specified URL. If no URL is specified, the default is used.
/// Returns a hashmap specifying the versions of the forge mod loader
/// The hashmap key is a Minecraft version, and the value is the loader versions that work on
/// the specified Minecraft version
pub async fn fetch_maven_metadata(
url: Option<&str>,
) -> Result<HashMap<String, Vec<String>>, Error> {
Ok(serde_json::from_slice(
&download_file(url.unwrap_or(DEFAULT_MAVEN_METADATA_URL), None).await?,
)?)
}