use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::utils::platform::LibraryRule;
#[derive(Debug, Clone, Deserialize)]
pub struct MojangVersionManifest {
pub latest: LatestVersions,
pub versions: Vec<VersionEntry>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct LatestVersions {
pub release: String,
pub snapshot: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VersionEntry {
pub id: String,
#[serde(rename = "type")]
pub version_type: String,
pub url: String,
pub time: String,
pub release_time: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MinecraftVersionJson {
pub id: String,
#[serde(rename = "type")]
pub version_type: String,
pub assets: Option<String>,
pub asset_index: Option<AssetIndexRef>,
pub downloads: Option<VersionDownloads>,
#[serde(default)]
pub libraries: Vec<Library>,
pub main_class: Option<String>,
pub java_version: Option<JavaVersionInfo>,
pub minecraft_arguments: Option<String>,
pub arguments: Option<Arguments>,
#[serde(rename = "nativesList", default)]
pub has_natives: bool,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AssetIndexRef {
pub id: String,
pub sha1: String,
pub size: u64,
pub total_size: Option<u64>,
pub url: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct VersionDownloads {
pub client: DownloadArtifact,
pub server: Option<DownloadArtifact>,
pub client_mappings: Option<DownloadArtifact>,
pub server_mappings: Option<DownloadArtifact>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DownloadArtifact {
pub sha1: String,
pub size: u64,
pub url: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct JavaVersionInfo {
pub component: Option<String>,
pub major_version: Option<u32>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Arguments {
pub game: Option<Vec<GameArgEntry>>,
pub jvm: Option<Vec<serde_json::Value>>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum GameArgEntry {
Plain(String),
Conditional(serde_json::Value),
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Library {
pub name: String,
pub rules: Option<Vec<LibraryRule>>,
pub natives: Option<HashMap<String, String>>,
pub downloads: Option<LibraryDownloads>,
#[serde(default)]
pub url: Option<String>,
#[serde(default)]
pub loader: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct LibraryDownloads {
pub artifact: Option<ArtifactInfo>,
pub classifiers: Option<HashMap<String, ArtifactInfo>>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ArtifactInfo {
pub sha1: Option<String>,
pub size: Option<u64>,
pub path: Option<String>,
pub url: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct AssetIndexData {
pub objects: HashMap<String, AssetObject>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct AssetObject {
pub hash: String,
pub size: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "kind", rename_all = "camelCase")]
pub enum AssetItem {
CFile { path: String, content: String },
Asset {
path: String,
sha1: String,
size: u64,
url: String,
},
NativeAsset {
path: String,
sha1: String,
size: u64,
url: String,
},
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Authenticator {
pub access_token: String,
pub name: String,
pub uuid: String,
#[serde(default)]
pub xbox_account: Option<XboxAccount>,
#[serde(default)]
pub user_properties: Option<String>,
#[serde(default)]
pub client_id: Option<String>,
#[serde(default)]
pub client_token: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct XboxAccount {
pub xuid: String,
}