use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum LoaderType {
Forge,
NeoForge,
Fabric,
LegacyFabric,
Quilt,
}
impl std::fmt::Display for LoaderType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
LoaderType::Forge => "forge",
LoaderType::NeoForge => "neoforge",
LoaderType::Fabric => "fabric",
LoaderType::LegacyFabric => "legacyfabric",
LoaderType::Quilt => "quilt",
};
f.write_str(s)
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct LoaderLibrary {
pub name: String,
#[serde(default)]
pub url: Option<String>,
pub downloads: Option<LoaderLibraryDownloads>,
#[serde(default)]
pub rules: Option<Vec<Value>>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct LoaderLibraryDownloads {
pub artifact: Option<LoaderArtifact>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct LoaderArtifact {
pub sha1: Option<String>,
pub size: Option<u64>,
pub path: Option<String>,
pub url: String,
}
#[derive(Debug, Deserialize)]
pub struct FabricMeta {
pub game: Vec<FabricGameVersion>,
pub loader: Vec<FabricLoaderBuild>,
}
#[derive(Debug, Deserialize)]
pub struct FabricGameVersion {
pub version: String,
pub stable: bool,
}
#[derive(Debug, Deserialize)]
pub struct FabricLoaderBuild {
pub version: String,
pub stable: bool,
}
#[derive(Debug, Deserialize)]
pub struct QuiltLoaderBuild {
pub version: String,
#[serde(default)]
pub stable: bool,
}
#[derive(Debug, Deserialize)]
pub struct QuiltMeta {
pub game: Vec<FabricGameVersion>,
pub loader: Vec<QuiltLoaderBuild>,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FabricJson {
pub id: String,
#[serde(default)]
pub libraries: Vec<LoaderLibrary>,
pub main_class: Option<String>,
pub minecraft_arguments: Option<String>,
#[serde(flatten)]
pub extra: HashMap<String, Value>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct ProfileDataEntry {
pub client: String,
#[serde(default)]
pub server: Option<String>,
}
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct ForgeArguments {
#[serde(default)]
pub game: Vec<serde_json::Value>,
#[serde(default)]
pub jvm: Vec<serde_json::Value>,
}
#[derive(Debug, Deserialize, Serialize, Default)]
#[serde(default)]
pub struct ForgeProfile {
pub install: Option<ForgeInstallSection>,
pub version: Option<ForgeVersionSection>,
pub data: Option<HashMap<String, ProfileDataEntry>>,
pub file_path: Option<String>,
pub path: Option<String>,
pub processors: Option<Vec<ForgeProcessor>>,
pub libraries: Option<Vec<LoaderLibrary>>,
}
#[derive(Debug, Deserialize, Serialize, Default)]
#[serde(rename_all = "camelCase", default)]
pub struct ForgeInstallSection {
pub libraries: Option<Vec<LoaderLibrary>>,
pub json: Option<String>,
pub path: Option<String>,
pub file_path: Option<String>,
pub minecraft: Option<String>,
pub processors: Option<Vec<ForgeProcessor>>,
#[serde(flatten)]
pub extra: HashMap<String, Value>,
}
#[derive(Debug, Deserialize, Serialize, Default)]
#[serde(rename_all = "camelCase", default)]
pub struct ForgeVersionSection {
pub id: Option<String>,
pub libraries: Option<Vec<LoaderLibrary>>,
pub main_class: Option<String>,
pub minecraft_arguments: Option<String>,
pub arguments: Option<ForgeArguments>,
#[serde(flatten)]
pub extra: HashMap<String, Value>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct ForgeProcessor {
pub jar: String,
pub classpath: Vec<String>,
pub args: Vec<String>,
#[serde(default)]
pub sides: Option<Vec<String>>,
}
#[derive(Debug)]
pub struct InstallerInfo {
pub file_path: String,
pub meta_data: String,
pub ext: String,
pub id: String,
pub old_api: bool,
}