fix: switch default profile to terminal and fixed some comments
This commit is contained in:
1 parent
971375bf1f
commit
52787b57c7
71 files changed
+671
-188
No files matched your search
@@ -1,3 +1,6 @@
|
||||
// fabric installation. the nice one: just fetch a profile json and download
|
||||
// the libraries. no java installer nonsense required.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// forge installation. unlike fabric/quilt, forge ships a java-based installer
|
||||
// that has to be downloaded and executed. yes, a jvm is needed just to install
|
||||
// the thing that runs on a jvm. the installer jar gets cleaned up afterward.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
@@ -39,6 +43,7 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
forge_api::download_forge_installer(client, game_version, loader_version, &installer_jar)
|
||||
.await?;
|
||||
|
||||
// use configured java or try to find one on PATH
|
||||
let java_path = crate::config::SETTINGS
|
||||
.paths
|
||||
.effective_java_path()
|
||||
@@ -47,6 +52,7 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
if let Err(e) =
|
||||
forge_api::run_forge_installer(&installer_jar, instance_dir, &java_path).await
|
||||
{
|
||||
// still clean up even if installation failed
|
||||
let _ = tokio::fs::remove_file(&installer_jar).await;
|
||||
return Err(e);
|
||||
}
|
||||
@@ -55,6 +61,7 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
tracing::warn!("Failed to remove Forge installer JAR: {}", e);
|
||||
}
|
||||
|
||||
// extract the profile from what the installer just wrote to disk
|
||||
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
mod vanilla;
|
||||
// mod loader installation. each loader (fabric, forge, neoforge, quilt, vanilla)
|
||||
// implements the same trait so the UI can treat them uniformly: pick game version,
|
||||
// pick loader version, install. the actual installation strategies differ wildly
|
||||
// though (fabric/quilt just download jars, forge/neoforge run a whole java installer).
|
||||
|
||||
mod fabric;
|
||||
mod forge;
|
||||
mod neoforge;
|
||||
mod quilt;
|
||||
mod vanilla;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -41,7 +46,6 @@ pub trait ModLoaderInstaller: Send + Sync {
|
||||
) -> Result<(), NetError>;
|
||||
}
|
||||
|
||||
/// Save a serializable loader profile JSON to `meta_dir/loader-profiles/<filename>`.
|
||||
pub(crate) fn save_profile_json(
|
||||
meta_dir: &Path,
|
||||
filename: &str,
|
||||
@@ -56,8 +60,9 @@ pub(crate) fn save_profile_json(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Read a Forge/NeoForge version JSON installed by the Java installer, extract
|
||||
/// mainClass + libraries, and save a simplified profile to `meta_dir/loader-profiles/`.
|
||||
// used by forge/neoforge. their java installer drops a version json into
|
||||
// .minecraft/versions/. parses that to extract the main class and library
|
||||
// list, then saves a stripped-down profile for use at launch time.
|
||||
pub(crate) fn save_installer_profile(
|
||||
instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
@@ -90,8 +95,12 @@ pub(crate) fn save_installer_profile(
|
||||
}
|
||||
|
||||
let raw = std::fs::read(&ver_json_path)?;
|
||||
let ver: InstallerVersionJson = serde_json::from_slice(&raw)
|
||||
.map_err(|e| NetError::Parse(format!("Invalid version JSON at {}: {e}", ver_json_path.display())))?;
|
||||
let ver: InstallerVersionJson = serde_json::from_slice(&raw).map_err(|e| {
|
||||
NetError::Parse(format!(
|
||||
"Invalid version JSON at {}: {e}",
|
||||
ver_json_path.display()
|
||||
))
|
||||
})?;
|
||||
|
||||
let libs: Vec<serde_json::Value> = ver
|
||||
.libraries
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// neoforge installation. same java installer dance as forge (they forked from it,
|
||||
// after all), just with different URLs and version naming.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// quilt installation. same clean approach as fabric (profile json + library
|
||||
// downloads). they're basically fabric's cooler sibling.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// vanilla "installer". doesn't actually install anything since the launch
|
||||
// process already handles downloading vanilla assets/libraries. this just
|
||||
// exists so vanilla fits the same ModLoaderInstaller trait as everyone else.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
Reference in new issue
Block a user