You've already forked AstralRinth
forked from didirus/AstralRinth
Authentication (#37)
* Initial authentication implementation * Store user info in the database, improve encapsulation in profiles * Add user list, remove unused dependencies, add spantraces * Implement user remove, update UUID crate * Add user set-default * Revert submodule macro usage * Make tracing significantly less verbose
This commit is contained in:
@@ -6,11 +6,11 @@ use tokio::process::{Child, Command};
|
||||
|
||||
mod args;
|
||||
|
||||
mod auth;
|
||||
pub use auth::Credentials;
|
||||
pub mod auth;
|
||||
|
||||
mod download;
|
||||
|
||||
#[tracing::instrument]
|
||||
pub fn parse_rule(rule: &d::minecraft::Rule) -> bool {
|
||||
use d::minecraft::{Rule, RuleAction};
|
||||
|
||||
@@ -44,6 +44,7 @@ macro_rules! processor_rules {
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all, fields(path = ?instance_path))]
|
||||
pub async fn launch_minecraft(
|
||||
game_version: &str,
|
||||
loader_version: &Option<d::modded::LoaderVersion>,
|
||||
@@ -64,7 +65,7 @@ pub async fn launch_minecraft(
|
||||
.versions
|
||||
.iter()
|
||||
.find(|it| it.id == game_version)
|
||||
.ok_or(crate::Error::LauncherError(format!(
|
||||
.ok_or(crate::ErrorKind::LauncherError(format!(
|
||||
"Invalid game version: {game_version}"
|
||||
)))?;
|
||||
|
||||
@@ -115,8 +116,9 @@ pub async fn launch_minecraft(
|
||||
}
|
||||
}
|
||||
|
||||
let mut cp = processor.classpath.clone();
|
||||
cp.push(processor.jar.clone());
|
||||
let cp = wrap_ref_builder!(cp = processor.classpath.clone() => {
|
||||
cp.push(processor.jar.clone())
|
||||
});
|
||||
|
||||
let child = Command::new("java")
|
||||
.arg("-cp")
|
||||
@@ -131,7 +133,7 @@ pub async fn launch_minecraft(
|
||||
)?)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::Error::LauncherError(format!(
|
||||
crate::ErrorKind::LauncherError(format!(
|
||||
"Could not find processor main class for {}",
|
||||
processor.jar
|
||||
))
|
||||
@@ -145,16 +147,17 @@ pub async fn launch_minecraft(
|
||||
.output()
|
||||
.await
|
||||
.map_err(|err| {
|
||||
crate::Error::LauncherError(format!(
|
||||
crate::ErrorKind::LauncherError(format!(
|
||||
"Error running processor: {err}",
|
||||
))
|
||||
})?;
|
||||
|
||||
if !child.status.success() {
|
||||
return Err(crate::Error::LauncherError(format!(
|
||||
return Err(crate::ErrorKind::LauncherError(format!(
|
||||
"Processor error: {}",
|
||||
String::from_utf8_lossy(&child.stderr)
|
||||
)));
|
||||
))
|
||||
.as_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,9 +166,7 @@ pub async fn launch_minecraft(
|
||||
let args = version_info.arguments.clone().unwrap_or_default();
|
||||
let mut command = match wrapper {
|
||||
Some(hook) => {
|
||||
let mut cmd = Command::new(hook);
|
||||
cmd.arg(java_install);
|
||||
cmd
|
||||
wrap_ref_builder!(it = Command::new(hook) => {it.arg(java_install)})
|
||||
}
|
||||
None => Command::new(String::from(java_install.to_string_lossy())),
|
||||
};
|
||||
@@ -203,10 +204,11 @@ pub async fn launch_minecraft(
|
||||
.stderr(Stdio::inherit());
|
||||
|
||||
command.spawn().map_err(|err| {
|
||||
crate::Error::LauncherError(format!(
|
||||
crate::ErrorKind::LauncherError(format!(
|
||||
"Error running Minecraft (minecraft-{} @ {}): {err}",
|
||||
&version.id,
|
||||
instance_path.display()
|
||||
))
|
||||
.as_error()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user