Files
Rocketmc/src/validate/neoforge.rs
Geometrically b8963d272a Update validators again (#925)
* Update validators again

* fix tests + clippy
2024-06-12 14:38:35 -07:00

38 lines
1.1 KiB
Rust

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)
}
}