Skip to content

Commit

Permalink
fix some data
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Apr 26, 2023
1 parent 568e5a9 commit 3afda71
Showing 1 changed file with 37 additions and 19 deletions.
56 changes: 37 additions & 19 deletions daedalus_client/src/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,48 @@ pub async fn retrieve_data(
let mut version_info =
daedalus::minecraft::fetch_version_info(version).await?;

let mut new_libraries = Vec::new();
for library in version_info.libraries {
if let Some(patch) = patches
fn patch_library(patches: &Vec<LibraryPatch>, mut library: Library) -> Vec<Library> {
let mut val = Vec::new();

let actual_patches = patches
.iter()
.find(|x| x.match_.contains(&library.name))
.filter(|x| x.match_.contains(&library.name))
.collect::<Vec<_>>();

if !actual_patches.is_empty()
{
if let Some(additional_libraries) =
&patch.additional_libraries
{
new_libraries.push(library);
for additional_library in additional_libraries {
new_libraries.push(additional_library.clone());
for patch in actual_patches {
if let Some(additional_libraries) =
&patch.additional_libraries
{
for additional_library in additional_libraries {
if patch.patch_additional_libraries.unwrap_or(false) {
let mut libs = patch_library(patches, additional_library.clone());
val.append(&mut libs)
} else {
val.push(additional_library.clone());
}
}
} else if let Some(override_) = &patch.override_ {
library = merge_partial_library(
override_.clone(),
library,
);
}
} else if let Some(override_) = &patch.override_ {
new_libraries.push(merge_partial_library(
override_.clone(),
library,
));
} else {
new_libraries.push(library);
}

val.push(library);
} else {
new_libraries.push(library);
val.push(library);
}

val
}

let mut new_libraries = Vec::new();
for library in version_info.libraries {
let mut libs = patch_library(&patches, library);
new_libraries.append(&mut libs)
}
version_info.libraries = new_libraries;

Expand Down Expand Up @@ -240,7 +258,7 @@ struct LibraryPatch {
pub additional_libraries: Option<Vec<Library>>,
#[serde(rename = "override")]
pub override_: Option<PartialLibrary>,
// pub patch_additional_libraries: Option<bool>,
pub patch_additional_libraries: Option<bool>,
}

/// Fetches the list of fabric versions
Expand Down

0 comments on commit 3afda71

Please sign in to comment.