From 0990ac4fc16677b86669f5bb03ed473891aee35f Mon Sep 17 00:00:00 2001 From: Jai A Date: Mon, 8 Nov 2021 20:17:20 -0700 Subject: [PATCH] Add forge data to main version info --- daedalus/Cargo.toml | 2 +- daedalus/src/minecraft.rs | 11 +++++++++++ daedalus/src/modded.rs | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/daedalus/Cargo.toml b/daedalus/Cargo.toml index 4f674a30..ef541991 100644 --- a/daedalus/Cargo.toml +++ b/daedalus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "daedalus" -version = "0.1.4" +version = "0.1.5" authors = ["Jai A "] edition = "2018" license = "MIT" diff --git a/daedalus/src/minecraft.rs b/daedalus/src/minecraft.rs index d345f04c..02d14424 100644 --- a/daedalus/src/minecraft.rs +++ b/daedalus/src/minecraft.rs @@ -1,3 +1,4 @@ +use crate::modded::{Processor, SidedDataEntry}; use crate::{download_file, Error}; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; @@ -51,9 +52,11 @@ pub struct Version { pub sha1: String, /// Whether the version supports the latest player safety features pub compliance_level: u32, + #[serde(skip_serializing_if = "Option::is_none")] /// (Modrinth Provided) The link to the assets index for this version /// This is only available when using the Modrinth mirror pub assets_index_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] /// (Modrinth Provided) The SHA1 hash of the assets index for this version /// This is only available when using the Modrinth mirror pub assets_index_sha1: Option, @@ -147,8 +150,10 @@ pub struct LibraryDownload { #[derive(Serialize, Deserialize, Debug)] /// A list of files that should be downloaded for libraries pub struct LibraryDownloads { + #[serde(skip_serializing_if = "Option::is_none")] /// The primary library artifact pub artifact: Option, + #[serde(skip_serializing_if = "Option::is_none")] /// Conditional files that may be needed to be downloaded alongside the library /// The HashMap key specifies a classifier as additional information for downloading files pub classifiers: Option>, @@ -315,6 +320,12 @@ pub struct VersionInfo { #[serde(rename = "type")] /// The type of version pub type_: VersionType, + #[serde(skip_serializing_if = "Option::is_none")] + /// (Forge-only) + pub data: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + /// (Forge-only) The list of processors to run after downloading the files + pub processors: Option>, } /// Fetches detailed information about a version from the manifest diff --git a/daedalus/src/modded.rs b/daedalus/src/modded.rs index 6cc42098..41289f34 100644 --- a/daedalus/src/modded.rs +++ b/daedalus/src/modded.rs @@ -31,10 +31,13 @@ pub struct PartialVersionInfo { pub release_time: DateTime, /// The latest time a file in this version was updated pub time: DateTime, + #[serde(skip_serializing_if = "Option::is_none")] /// The classpath to the main class to launch the game pub main_class: Option, + #[serde(skip_serializing_if = "Option::is_none")] /// (Legacy) Arguments passed to the game pub minecraft_arguments: Option, + #[serde(skip_serializing_if = "Option::is_none")] /// Arguments passed to the game or JVM pub arguments: Option>>, /// Libraries that the version depends on @@ -42,8 +45,10 @@ pub struct PartialVersionInfo { #[serde(rename = "type")] /// The type of version pub type_: VersionType, + #[serde(skip_serializing_if = "Option::is_none")] /// (Forge-only) pub data: Option>, + #[serde(skip_serializing_if = "Option::is_none")] /// (Forge-only) The list of processors to run after downloading the files pub processors: Option>, } @@ -57,8 +62,10 @@ pub struct Processor { pub classpath: Vec, /// Arguments for this processor. pub args: Vec, + #[serde(skip_serializing_if = "Option::is_none")] /// Represents a map of outputs. Keys and values can be data values pub outputs: Option>, + #[serde(skip_serializing_if = "Option::is_none")] /// Which sides this processor shall be ran on. /// Valid values: client, server, extract pub sides: Option>, @@ -120,6 +127,8 @@ pub fn merge_partial_version(partial: PartialVersionInfo, merge: VersionInfo) -> release_time: partial.release_time, time: partial.time, type_: partial.type_, + data: partial.data, + processors: partial.processors, } }