This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start work at modrinth plugin system
- Loading branch information
Showing
10 changed files
with
147 additions
and
144 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 was deleted.
Oops, something went wrong.
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,2 +1,2 @@ | ||
pub mod item; | ||
pub mod modrinth; | ||
pub mod vanilla; |
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,71 @@ | ||
use std::collections::HashMap; | ||
|
||
use md5::digest::typenum::Mod; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use serde_json::Value; | ||
|
||
use crate::config::downloader::ChooseHash; | ||
|
||
pub type Name = String; | ||
pub type Hash = ChooseHash; | ||
pub type ProjectID = String; | ||
pub type PluginID = String; | ||
pub type About = (Hash, ProjectID, PluginID); | ||
|
||
pub struct Modrinth { | ||
plugin: HashMap<Name, About> | ||
} | ||
///# Example | ||
///we have cdn like this: `https://cdn.modrinth.com/data/PROJECT_ID/versions/ID/NAME-LOADER-VERSION.jar` | ||
///we can take `[project_id]` -> `AANobbMI` | ||
///we can take `[id]` -> `4GyXKCLd` | ||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ModrinthData { | ||
//Always change ich version | ||
pub id: PluginID, | ||
//Stable token. | ||
pub project_id: ProjectID, | ||
pub files: Vec<File>, | ||
pub dependencies: Vec<Dependency>, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct File { | ||
pub hashes: Hashes, | ||
pub url: String, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Hashes { | ||
pub sha1: String, | ||
// pub sha512: String, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Dependency { | ||
#[serde(rename = "version_id")] | ||
pub version_id: Value, | ||
#[serde(rename = "file_name")] | ||
pub file_name: Value, | ||
#[serde(rename = "dependency_type")] | ||
pub dependency_type: String, | ||
} | ||
|
||
|
||
impl Modrinth { | ||
///Convert Vector of data to hashmap | ||
///for download files | ||
pub async fn convert(data: Vec<ModrinthData>) -> Self { | ||
let hashmap: HashMap<Name, About> = HashMap::new(); | ||
data.iter().map(|x| | ||
{ | ||
|
||
}); | ||
todo!() | ||
} | ||
} |
Oops, something went wrong.