This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update validators again * fix tests + clippy
- Loading branch information
1 parent
beaaed6
commit b8963d2
Showing
11 changed files
with
161 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::validate::{filter_out_packs, SupportedGameVersions, ValidationError, ValidationResult}; | ||
use std::io::Cursor; | ||
use zip::ZipArchive; | ||
|
||
pub struct NeoForgeValidator; | ||
|
||
impl super::Validator for NeoForgeValidator { | ||
fn get_file_extensions(&self) -> &[&str] { | ||
&["jar", "zip"] | ||
} | ||
|
||
fn get_supported_loaders(&self) -> &[&str] { | ||
&["forge"] | ||
} | ||
|
||
fn get_supported_game_versions(&self) -> SupportedGameVersions { | ||
SupportedGameVersions::All | ||
} | ||
|
||
fn validate( | ||
&self, | ||
archive: &mut ZipArchive<Cursor<bytes::Bytes>>, | ||
) -> Result<ValidationResult, ValidationError> { | ||
if archive.by_name("META-INF/mods.toml").is_err() | ||
&& archive.by_name("META-INF/neoforge.mods.toml").is_err() | ||
&& !archive.file_names().any(|x| x.ends_with(".class")) | ||
{ | ||
return Ok(ValidationResult::Warning( | ||
"No neoforge.mods.toml, mods.toml, or valid class files present for NeoForge file.", | ||
)); | ||
} | ||
|
||
filter_out_packs(archive)?; | ||
|
||
Ok(ValidationResult::Pass) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::validate::{filter_out_packs, SupportedGameVersions, ValidationError, ValidationResult}; | ||
use std::io::Cursor; | ||
use zip::ZipArchive; | ||
|
||
pub struct RiftValidator; | ||
|
||
impl super::Validator for RiftValidator { | ||
fn get_file_extensions(&self) -> &[&str] { | ||
&["jar"] | ||
} | ||
|
||
fn get_supported_loaders(&self) -> &[&str] { | ||
&["rift"] | ||
} | ||
|
||
fn get_supported_game_versions(&self) -> SupportedGameVersions { | ||
SupportedGameVersions::All | ||
} | ||
|
||
fn validate( | ||
&self, | ||
archive: &mut ZipArchive<Cursor<bytes::Bytes>>, | ||
) -> Result<ValidationResult, ValidationError> { | ||
if archive.by_name("riftmod.json").is_err() { | ||
return Ok(ValidationResult::Warning( | ||
"No riftmod.json present for Rift file.", | ||
)); | ||
} | ||
|
||
filter_out_packs(archive)?; | ||
|
||
Ok(ValidationResult::Pass) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters