You've already forked AstralRinth
Use the log config from the Vanilla client.json (#3411)
* Use the log config from the Vanilla client.json * Remove debug message --------- Co-authored-by: Jai Agrawal <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::{
|
||||
state::{MemorySettings, WindowSize},
|
||||
util::{io::IOError, platform::classpath_separator},
|
||||
};
|
||||
use daedalus::minecraft::LoggingConfiguration;
|
||||
use daedalus::{
|
||||
get_path_from_artifact,
|
||||
minecraft::{Argument, ArgumentValue, Library, VersionType},
|
||||
@@ -104,11 +105,13 @@ pub fn get_jvm_arguments(
|
||||
arguments: Option<&[Argument]>,
|
||||
natives_path: &Path,
|
||||
libraries_path: &Path,
|
||||
log_configs_path: &Path,
|
||||
class_paths: &str,
|
||||
version_name: &str,
|
||||
memory: MemorySettings,
|
||||
custom_args: Vec<String>,
|
||||
java_arch: &str,
|
||||
log_config: Option<&LoggingConfiguration>,
|
||||
) -> crate::Result<Vec<String>> {
|
||||
let mut parsed_arguments = Vec::new();
|
||||
|
||||
@@ -143,6 +146,12 @@ pub fn get_jvm_arguments(
|
||||
parsed_arguments.push(class_paths.to_string());
|
||||
}
|
||||
parsed_arguments.push(format!("-Xmx{}M", memory.maximum));
|
||||
if let Some(LoggingConfiguration::Log4j2Xml { argument, file }) = log_config
|
||||
{
|
||||
let full_path = log_configs_path.join(&file.id);
|
||||
let full_path = full_path.to_string_lossy();
|
||||
parsed_arguments.push(argument.replace("${path}", &full_path));
|
||||
}
|
||||
for arg in custom_args {
|
||||
if !arg.is_empty() {
|
||||
parsed_arguments.push(arg);
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::{
|
||||
state::State,
|
||||
util::{fetch::*, io, platform::OsExt},
|
||||
};
|
||||
use daedalus::minecraft::{LoggingConfiguration, LoggingSide};
|
||||
use daedalus::{
|
||||
self as d,
|
||||
minecraft::{
|
||||
@@ -48,7 +49,8 @@ pub async fn download_minecraft(
|
||||
|
||||
tokio::try_join! {
|
||||
// Total loading sums to 90/60
|
||||
download_client(st, version, Some(loading_bar), force), // 10
|
||||
download_client(st, version, Some(loading_bar), force), // 9
|
||||
download_log_config(st, version, Some(loading_bar), force),
|
||||
download_assets(st, version.assets == "legacy", &assets_index, Some(loading_bar), amount, force), // 40
|
||||
download_libraries(st, version.libraries.as_slice(), &version.id, Some(loading_bar), amount, java_arch, force, minecraft_updated) // 40
|
||||
}?;
|
||||
@@ -80,7 +82,11 @@ pub async fn download_version_info(
|
||||
.await
|
||||
.and_then(|ref it| Ok(serde_json::from_slice(it)?))
|
||||
} else {
|
||||
tracing::info!("Downloading version info for version {}", &version.id);
|
||||
tracing::info!(
|
||||
"Downloading version info for version {} from {}",
|
||||
&version.id,
|
||||
version.url
|
||||
);
|
||||
let mut info = fetch_json(
|
||||
Method::GET,
|
||||
&version.url,
|
||||
@@ -376,3 +382,45 @@ pub async fn download_libraries(
|
||||
tracing::debug!("Done loading libraries!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn download_log_config(
|
||||
st: &State,
|
||||
version_info: &GameVersionInfo,
|
||||
loading_bar: Option<&LoadingBarId>,
|
||||
force: bool,
|
||||
) -> crate::Result<()> {
|
||||
let log_download = version_info
|
||||
.logging
|
||||
.as_ref()
|
||||
.and_then(|x| x.get(&LoggingSide::Client));
|
||||
let Some(LoggingConfiguration::Log4j2Xml {
|
||||
file: log_download, ..
|
||||
}) = log_download
|
||||
else {
|
||||
if let Some(loading_bar) = loading_bar {
|
||||
emit_loading(loading_bar, 1.0, None)?;
|
||||
}
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let path = st.directories.log_configs_dir().join(&log_download.id);
|
||||
|
||||
if !path.exists() || force {
|
||||
let bytes = fetch(
|
||||
&log_download.url,
|
||||
Some(&log_download.sha1),
|
||||
&st.fetch_semaphore,
|
||||
&st.pool,
|
||||
)
|
||||
.await?;
|
||||
write(&path, &bytes, &st.io_semaphore).await?;
|
||||
tracing::trace!("Fetched log config {}", log_download.id);
|
||||
}
|
||||
if let Some(loading_bar) = loading_bar {
|
||||
emit_loading(loading_bar, 1.0, None)?;
|
||||
}
|
||||
|
||||
tracing::debug!("Log config {} loaded", log_download.id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
use crate::data::ModLoader;
|
||||
use crate::event::emit::{emit_loading, init_or_edit_loading};
|
||||
use crate::event::{LoadingBarId, LoadingBarType};
|
||||
use crate::launcher::download::download_log_config;
|
||||
use crate::launcher::io::IOError;
|
||||
use crate::state::{
|
||||
Credentials, JavaVersion, ProcessMetadata, ProfileInstallStage,
|
||||
@@ -10,7 +11,7 @@ use crate::util::io;
|
||||
use crate::{process, state as st, State};
|
||||
use chrono::Utc;
|
||||
use daedalus as d;
|
||||
use daedalus::minecraft::{RuleAction, VersionInfo};
|
||||
use daedalus::minecraft::{LoggingSide, RuleAction, VersionInfo};
|
||||
use daedalus::modded::LoaderVersion;
|
||||
use st::Profile;
|
||||
use std::collections::HashMap;
|
||||
@@ -481,7 +482,7 @@ pub async fn launch_minecraft(
|
||||
format!("{}-{}", version.id.clone(), it.id.clone())
|
||||
});
|
||||
|
||||
let version_info = download::download_version_info(
|
||||
let mut version_info = download::download_version_info(
|
||||
&state,
|
||||
version,
|
||||
loader_version.as_ref(),
|
||||
@@ -489,6 +490,26 @@ pub async fn launch_minecraft(
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
if version_info.logging.is_none() {
|
||||
let requires_logging_info = version_index
|
||||
<= minecraft
|
||||
.versions
|
||||
.iter()
|
||||
.position(|x| x.id == "13w39a")
|
||||
.unwrap_or(0);
|
||||
if requires_logging_info {
|
||||
version_info = download::download_version_info(
|
||||
&state,
|
||||
version,
|
||||
loader_version.as_ref(),
|
||||
Some(true),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
download_log_config(&state, &version_info, None, false).await?;
|
||||
|
||||
let java_version = get_java_version_from_profile(profile, &version_info)
|
||||
.await?
|
||||
@@ -548,6 +569,7 @@ pub async fn launch_minecraft(
|
||||
.map(|x| x.as_slice()),
|
||||
&natives_dir,
|
||||
&state.directories.libraries_dir(),
|
||||
&state.directories.log_configs_dir(),
|
||||
&args::get_class_paths(
|
||||
&state.directories.libraries_dir(),
|
||||
version_info.libraries.as_slice(),
|
||||
@@ -559,6 +581,10 @@ pub async fn launch_minecraft(
|
||||
*memory,
|
||||
Vec::from(java_args),
|
||||
&java_version.architecture,
|
||||
version_info
|
||||
.logging
|
||||
.as_ref()
|
||||
.and_then(|x| x.get(&LoggingSide::Client)),
|
||||
)?
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>(),
|
||||
|
||||
@@ -106,6 +106,12 @@ impl DirectoryInfo {
|
||||
self.objects_dir().join(&hash[..2]).join(hash)
|
||||
}
|
||||
|
||||
/// Get the Minecraft log config's directory
|
||||
#[inline]
|
||||
pub fn log_configs_dir(&self) -> PathBuf {
|
||||
self.metadata_dir().join("log_configs")
|
||||
}
|
||||
|
||||
/// Get the Minecraft legacy assets metadata directory
|
||||
#[inline]
|
||||
pub fn legacy_assets_dir(&self) -> PathBuf {
|
||||
|
||||
Reference in New Issue
Block a user