* basic push

* actual push

* JRE detection, and autosetting

* removed a println, retrying CI/CD

* new game version compare; preset java 7 and 8 using our jre

* 1.8 mislabeled

* working JRE changes

* fixed bugs with JRE setup

* fixed bugs with JRE setup

* manual merge

* prettier

* fixes + jre 17

* clippy, prettier

* typo

* forgot to hook up a function

* pr fix + comment fix

* added loader_version

* take 2
This commit is contained in:
Wyatt Verchere
2023-04-07 13:31:06 -07:00
committed by GitHub
parent 4b41ffbd8a
commit 34005dd2e2
21 changed files with 542 additions and 83 deletions

View File

@@ -1,10 +1,9 @@
//! Theseus profile management interface
use crate::state::MinecraftChild;
use crate::{launcher::download, state::MinecraftChild};
pub use crate::{
state::{JavaSettings, Profile},
State,
};
use daedalus as d;
use std::{
future::Future,
path::{Path, PathBuf},
@@ -120,8 +119,8 @@ pub async fn run(
profile.metadata.game_version
))
})?;
let version_info = d::minecraft::fetch_version_info(version).await?;
let version_info =
download::download_version_info(&state, version, profile.metadata.loader_version.as_ref()).await?;
let pre_launch_hooks =
&profile.hooks.as_ref().unwrap_or(&settings.hooks).pre_launch;
for hook in pre_launch_hooks.iter() {
@@ -145,29 +144,42 @@ pub async fn run(
}
}
let java_install = match profile.java {
let java_version = match profile.java {
// Load profile-specific Java implementation choice
// (This defaults to Daedalus-decided key on init, but can be changed by the user)
Some(JavaSettings {
install: Some(ref install),
jre_key: Some(ref jre_key),
..
}) => install,
_ => if version_info
.java_version
.as_ref()
.filter(|it| it.major_version >= 16)
.is_some()
{
settings.java_17_path.as_ref()
} else {
settings.java_8_path.as_ref()
}) => settings.java_globals.get(jre_key),
// Fall back to Daedalus-decided key if no profile-specific key is set
_ => {
match version_info
.java_version
.as_ref()
.map(|it| it.major_version)
.unwrap_or(0)
{
0..=16 => settings
.java_globals
.get(&crate::jre::JAVA_8_KEY.to_string()),
17 => settings
.java_globals
.get(&crate::jre::JAVA_17_KEY.to_string()),
_ => settings
.java_globals
.get(&crate::jre::JAVA_18PLUS_KEY.to_string()),
}
}
.ok_or_else(|| {
crate::ErrorKind::LauncherError(format!(
"No Java installed for version {}",
version_info.java_version.map_or(8, |it| it.major_version),
))
})?,
};
let java_version = java_version.as_ref().ok_or_else(|| {
crate::ErrorKind::LauncherError(format!(
"No Java stored for version {}",
version_info.java_version.map_or(8, |it| it.major_version),
))
})?;
// Get the path to the Java executable from the chosen Java implementation key
let java_install: &Path = &PathBuf::from(&java_version.path);
if !java_install.exists() {
return Err(crate::ErrorKind::LauncherError(format!(
"Could not find Java install: {}",
@@ -175,7 +187,6 @@ pub async fn run(
))
.as_error());
}
let java_args = profile
.java
.as_ref()