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.
- Loading branch information
Showing
7 changed files
with
107 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod item; | ||
pub mod vanila; |
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,74 @@ | ||
use log::info; | ||
use reqwest::Request; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
use crate::config::ConfigErrors; | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Vanila { | ||
pub latest: Latest, | ||
pub versions: Vec<Version>, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Latest { | ||
pub release: String, | ||
pub snapshot: String, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Version { | ||
pub id: String, | ||
#[serde(rename = "type")] | ||
#[serde(skip)] | ||
pub type_field: String, | ||
pub url: String, | ||
#[serde(skip)] | ||
pub time: String, | ||
#[serde(skip)] | ||
pub release_time: String, | ||
} | ||
|
||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct DownloadSection { | ||
pub downloads: Downloads, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Downloads { | ||
pub server: Server, | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Server { | ||
pub sha1: String, | ||
pub url: String, | ||
} | ||
|
||
impl Vanila { | ||
///Making request to mojang api and find the link to download minecraft.jar | ||
pub async fn find(version: &str) -> Result<(), ConfigErrors> { | ||
const LINK: &str = "https://piston-meta.mojang.com/v1/packages/8bcd47def18efee744bd0700e86ab44a96ade21f/1.20.4.json"; | ||
let body = match reqwest::get(LINK).await { | ||
Ok(e) => {match e.json::<DownloadSection>().await { | ||
Ok(e) => {e.downloads.server}, | ||
Err(e) => {Err(ConfigErrors::LoadCorrapt(e.to_string()))}?, | ||
}}, | ||
Err(e) => {Err(ConfigErrors::LoadCorrapt(e.to_string()))}?, | ||
}; | ||
info!("Check body: {:#?}", &body); | ||
Ok(()) | ||
} | ||
|
||
pub async fn download(link: &str) { | ||
todo!() | ||
} | ||
} |