Skip to content

Commit

Permalink
NeoForge formatting change
Browse files Browse the repository at this point in the history
  • Loading branch information
Loudbooks committed Feb 1, 2024
1 parent 2d4fb14 commit 43a579f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/downloaders/neoforge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ pub(crate) struct NeoForge {}

impl Downloader for NeoForge {
async fn download(client: reqwest::Client, minecraft_version: Option<String>) -> Result<String, crate::downloaderror::DownloadError> {
let neo_version = get_neoforge_version(minecraft_version).await.expect("Failed to get latest Neoforge version");
let neo_version = get_neoforge_version(minecraft_version).await.expect("Failed to get latest NeoForge version");

println!("Using Neoforge version {}.", neo_version);
println!("Using NeoForge version {}.", neo_version);

let url = format!(
"https://maven.neoforged.net/releases/net/neoforged/neoforge/{}/neoforge-{}-installer.jar",
Expand Down Expand Up @@ -41,11 +41,11 @@ pub async fn build_server(java_path: String, mut minecraft_version: Option<Strin
.spawn()
.expect("Failed to build server");

println!("Building server with Neoforge version {}. This will take a while...", minecraft_version.clone().unwrap_or("".to_string()));
println!("Building server with NeoForge version {}. This will take a while...", minecraft_version.clone().unwrap_or("".to_string()));

process.wait().expect("Failed to build server");

fs::remove_file("neoforge.jar").await.expect("Failed to remove Neoforge jar");
fs::remove_file("neoforge.jar").await.expect("Failed to remove NeoForge jar");
fs::rename("run.sh", "launch.sh").await.expect("Failed to rename run.sh to launch.sh");

let mut content = String::new();
Expand All @@ -68,21 +68,21 @@ pub async fn build_server(java_path: String, mut minecraft_version: Option<Strin
}

async fn get_version_array() -> Vec<Value> {
let response = reqwest::get("https://maven.neoforged.net/releases/net/neoforged/neoforge//maven-metadata.xml").await.expect("Failed to get Neoforge metadata");
let body = response.text().await.expect("Failed to get Neoforge metadata");
let response = reqwest::get("https://maven.neoforged.net/releases/net/neoforged/neoforge//maven-metadata.xml").await.expect("Failed to get NeoForge metadata");
let body = response.text().await.expect("Failed to get NeoForge metadata");
let builder = JsonBuilder::default();
let json = builder.build_from_xml(body.as_str()).unwrap();

json.get("metadata").expect("Failed step 1 of Neoforge")
.get("versioning").expect("Failed step 2 of Neoforge")
.as_array().expect("Failed step 3 of Neoforge")
.first().expect("Failed step 4 of Neoforge")
.get("versions").expect("Failed step 5 of Neoforge")
.as_array().expect("Failed step 6 of Neoforge")
.first().expect("Failed step 7 of Neoforge")
.as_object().expect("Failed step 8 of Neoforge")
.get("version").expect("Failed step 9 of Neoforge")
.as_array().expect("Failed step 10 of Neoforge")
json.get("metadata").expect("Failed step 1 of NeoForge")
.get("versioning").expect("Failed step 2 of NeoForge")
.as_array().expect("Failed step 3 of NeoForge")
.first().expect("Failed step 4 of NeoForge")
.get("versions").expect("Failed step 5 of NeoForge")
.as_array().expect("Failed step 6 of NeoForge")
.first().expect("Failed step 7 of NeoForge")
.as_object().expect("Failed step 8 of NeoForge")
.get("version").expect("Failed step 9 of NeoForge")
.as_array().expect("Failed step 10 of NeoForge")
.to_owned()
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async fn main() {
println!("2. Paper - A Minecraft server with plugins.");
println!("3. Fabric - A Minecraft server with Fabric mods.");
println!("4. Forge - A Minecraft server with Forge mods.");
println!("5. Neoforge - A Minecraft server with Neoforge mods.");
println!("5. NeoForge - A Minecraft server with NeoForge mods.");
println!();
print!("Enter the number of the server you want to run: (1-5): ");

Expand Down Expand Up @@ -182,7 +182,7 @@ async fn main() {
Forge::download(client.clone(), version_option.clone()).await.expect("Failed to download Forge");
forge::build_server(java_path.clone(), version_option).await;
} else if num == 5 {
NeoForge::download(client.clone(), version_option.clone()).await.expect("Failed to download Neoforge");
NeoForge::download(client.clone(), version_option.clone()).await.expect("Failed to download NeoForge");
neoforge::build_server(java_path.clone(), version_option).await;
}

Expand Down

0 comments on commit 43a579f

Please sign in to comment.