You've already forked AstralRinth
* Add dependencies to search * add attrs for faceting * run prepare * Add user data route from token * update to 24hrs * Fix report bugs
37 lines
974 B
Rust
37 lines
974 B
Rust
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
|
|
use std::io::Cursor;
|
|
use zip::ZipArchive;
|
|
|
|
pub struct DataPackValidator;
|
|
|
|
impl super::Validator for DataPackValidator {
|
|
fn get_file_extensions(&self) -> &[&str] {
|
|
&["zip"]
|
|
}
|
|
|
|
fn get_project_types(&self) -> &[&str] {
|
|
&["mod"]
|
|
}
|
|
|
|
fn get_supported_loaders(&self) -> &[&str] {
|
|
&["datapack"]
|
|
}
|
|
|
|
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("pack.mcmeta").is_err() {
|
|
return Ok(ValidationResult::Warning(
|
|
"No pack.mcmeta present for datapack file. Tip: Make sure pack.mcmeta is in the root directory of your datapack!",
|
|
));
|
|
}
|
|
|
|
Ok(ValidationResult::Pass)
|
|
}
|
|
}
|