2024-10-18 16:07:35 -07:00
|
|
|
use crate::validate::{
|
2025-05-09 07:27:55 -05:00
|
|
|
SupportedGameVersions, ValidationError, ValidationResult, filter_out_packs,
|
2024-10-18 16:07:35 -07:00
|
|
|
};
|
2022-05-26 10:08:19 -07:00
|
|
|
use std::io::Cursor;
|
|
|
|
|
use zip::ZipArchive;
|
|
|
|
|
|
|
|
|
|
pub struct LiteLoaderValidator;
|
|
|
|
|
|
|
|
|
|
impl super::Validator for LiteLoaderValidator {
|
|
|
|
|
fn get_file_extensions(&self) -> &[&str] {
|
2022-09-02 12:38:58 -07:00
|
|
|
&["litemod", "jar"]
|
2022-05-26 10:08:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_supported_loaders(&self) -> &[&str] {
|
|
|
|
|
&["liteloader"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_supported_game_versions(&self) -> SupportedGameVersions {
|
|
|
|
|
SupportedGameVersions::All
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn validate(
|
|
|
|
|
&self,
|
|
|
|
|
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
|
|
|
|
) -> Result<ValidationResult, ValidationError> {
|
2023-04-16 20:03:53 -07:00
|
|
|
if archive.by_name("litemod.json").is_err() {
|
|
|
|
|
return Ok(ValidationResult::Warning(
|
|
|
|
|
"No litemod.json present for LiteLoader file.",
|
|
|
|
|
));
|
|
|
|
|
}
|
2022-05-26 10:08:19 -07:00
|
|
|
|
2024-06-12 14:38:35 -07:00
|
|
|
filter_out_packs(archive)?;
|
|
|
|
|
|
2022-05-26 10:08:19 -07:00
|
|
|
Ok(ValidationResult::Pass)
|
|
|
|
|
}
|
|
|
|
|
}
|