-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5faefc
commit 0a973f5
Showing
20 changed files
with
390 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,34 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default)] | ||
pub enum AddonMetadataSource { | ||
Modrinth, | ||
Curseforge, | ||
Hangar, | ||
Github, | ||
Spigot, | ||
#[default] | ||
Other, | ||
} | ||
|
||
impl AddonMetadataSource { | ||
pub fn into_str(&self) -> &'static str { | ||
Check warning on line 16 in src/api/models/addon/addon_metadata.rs GitHub Actions / clippythis argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
Check failure on line 16 in src/api/models/addon/addon_metadata.rs GitHub Actions / clippymethods called `into_*` usually take `self` by value
Check warning on line 16 in src/api/models/addon/addon_metadata.rs GitHub Actions / clippymethod `into_str` is never used
|
||
match self { | ||
AddonMetadataSource::Modrinth => "modrinth", | ||
AddonMetadataSource::Hangar => "hangar", | ||
AddonMetadataSource::Spigot => "spigot", | ||
AddonMetadataSource::Other => "other", | ||
AddonMetadataSource::Github => "github", | ||
AddonMetadataSource::Curseforge => "curseforge", | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct AddonMetadata { | ||
pub name: String, | ||
pub version: String, | ||
pub link: String, | ||
pub source: AddonMetadataSource, | ||
} |
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 |
---|---|---|
@@ -1,10 +1,24 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::mrpack::{Env, EnvSupport}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash, Default)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum Environment { | ||
#[default] | ||
#[serde(alias = "*")] | ||
Both, | ||
#[serde(alias = "dedicated_server")] | ||
Server, | ||
Client, | ||
} | ||
|
||
impl From<Env> for Environment { | ||
fn from(value: Env) -> Self { | ||
match (value.client, value.server) { | ||
(EnvSupport::Unsupported, EnvSupport::Optional | EnvSupport::Required) => Environment::Server, | ||
(EnvSupport::Optional | EnvSupport::Required, EnvSupport::Unsupported) => Environment::Client, | ||
_ => Environment::Both, | ||
} | ||
} | ||
} |
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,63 @@ | ||
use std::collections::HashMap; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::api::{models::Environment, utils::serde::{SingleOrArray, SingleOrHashMap}}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub enum Person { | ||
String(String), | ||
Object { | ||
name: String, | ||
contact: HashMap<String, String>, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct NestedJarEntry { | ||
pub file: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub enum MixinEntry { | ||
String(String), | ||
Object { | ||
config: String, | ||
// ??? | ||
}, | ||
} | ||
|
||
pub type VersionRange = SingleOrArray<String>; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct FabricModJson { | ||
pub id: String, | ||
pub version: String, | ||
|
||
pub name: Option<String>, | ||
pub description: Option<String>, | ||
pub authors: Vec<Person>, | ||
pub contributors: Vec<Person>, | ||
pub contact: HashMap<String, String>, | ||
|
||
pub license: SingleOrArray<String>, | ||
pub icon: SingleOrHashMap<String, String>, | ||
|
||
pub environment: Option<SingleOrArray<Environment>>, | ||
pub entrypoints: (), | ||
pub jars: Vec<NestedJarEntry>, | ||
pub language_adapters: HashMap<String, String>, | ||
pub mixins: (), | ||
pub access_widener: Option<String>, | ||
|
||
pub depends: HashMap<String, VersionRange>, | ||
pub recommends: HashMap<String, VersionRange>, | ||
pub suggests: HashMap<String, VersionRange>, | ||
pub conflicts: HashMap<String, VersionRange>, | ||
pub breaks: HashMap<String, VersionRange>, | ||
|
||
pub custom: HashMap<String, serde_json::Value>, | ||
} | ||
|
||
|
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,2 @@ | ||
pub mod fabric; | ||
pub mod quilt; |
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,84 @@ | ||
use std::{collections::HashMap, str::FromStr}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{api::{models::Environment, utils::serde::{str_default, string_or_struct, SingleOrArray}}, generate_de_vec}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct QuiltModJson { | ||
pub quilt_loader: QuiltModJsonLoader, | ||
pub minecraft: Option<QuiltModJsonMinecraft>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct QuiltEntrypoint { | ||
#[serde(default = "str_default")] | ||
pub adapter: String, | ||
pub value: String, | ||
} | ||
|
||
impl FromStr for QuiltEntrypoint { | ||
type Err = (); | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(Self { | ||
adapter: str_default(), | ||
value: s.to_owned(), | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct QuiltDependency { | ||
pub id: String, | ||
pub versions: Option<serde_json::Value>, | ||
pub reason: Option<String>, | ||
pub optional: bool, | ||
pub unless: Option<Box<QuiltDependency>>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct QuiltProvides { | ||
pub id: String, | ||
pub version: Option<String>, | ||
} | ||
|
||
generate_de_vec!(QuiltProvides, de_vec_quilt_provides, "string_or_struct"); | ||
generate_de_vec!(QuiltEntrypoint, de_vec_quilt_entrypoint, "string_or_struct"); | ||
|
||
impl FromStr for QuiltProvides { | ||
type Err = (); | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(Self { | ||
id: s.to_owned(), | ||
version: None, | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct QuiltModJsonLoader { | ||
pub group: String, | ||
pub id: String, | ||
pub version: String, | ||
#[serde(deserialize_with = "de_vec_quilt_provides")] | ||
#[serde(default = "Vec::new")] | ||
pub provides: Vec<QuiltProvides>, | ||
#[serde(default = "HashMap::new")] | ||
pub entrypoints: HashMap<String, SingleOrArray<QuiltEntrypoint>>, | ||
#[serde(deserialize_with = "de_vec_quilt_entrypoint")] | ||
#[serde(default = "Vec::new")] | ||
pub plugins: Vec<QuiltEntrypoint>, | ||
#[serde(default = "Vec::new")] | ||
pub jars: Vec<String>, | ||
#[serde(default = "HashMap::new")] | ||
pub language_adapters: HashMap<String, String>, | ||
|
||
} | ||
|
||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct QuiltModJsonMinecraft { | ||
pub environment: Environment, | ||
} |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub const NETWORK_TOML: &str = "network.toml"; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct Network { | ||
pub name: String, | ||
} |
Oops, something went wrong.