diff --git a/.idea/discord.xml b/.idea/discord.xml
new file mode 100644
index 000000000..d8e956166
--- /dev/null
+++ b/.idea/discord.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index f88a687a4..84bfe7104 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
+version = 3
+
[[package]]
name = "adler"
version = "1.0.2"
@@ -123,6 +125,22 @@ dependencies = [
"cfg-if",
]
+[[package]]
+name = "daedalus"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "667dec20054908ee40916a3fd8ea5bfc6ed8b1bde6f7741dbea18500a1049ea6"
+dependencies = [
+ "bytes",
+ "chrono",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "sha1",
+ "thiserror",
+ "tokio",
+]
+
[[package]]
name = "encoding_rs"
version = "0.8.28"
@@ -636,6 +654,12 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "path-clean"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd"
+
[[package]]
name = "percent-encoding"
version = "2.1.0"
@@ -972,8 +996,10 @@ version = "0.1.0"
dependencies = [
"bytes",
"chrono",
+ "daedalus",
"futures",
"lazy_static",
+ "path-clean",
"regex",
"reqwest",
"serde",
diff --git a/theseus/Cargo.toml b/theseus/Cargo.toml
index c4d8a9f57..a1750dcfe 100644
--- a/theseus/Cargo.toml
+++ b/theseus/Cargo.toml
@@ -9,6 +9,8 @@ edition = "2018"
[dependencies]
thiserror = "1.0"
+daedalus = "0.1.6"
+
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
@@ -17,6 +19,7 @@ uuid = { version = "0.8", features = ["serde", "v4"] }
bytes = "1"
zip = "0.5"
sha1 = { version = "0.6.0", features = ["std"]}
+path-clean = "0.1.0"
regex = "1.5"
lazy_static = "1.4"
diff --git a/theseus/src/launcher/args.rs b/theseus/src/launcher/args.rs
index a7e9b47d4..46dc99fc2 100644
--- a/theseus/src/launcher/args.rs
+++ b/theseus/src/launcher/args.rs
@@ -1,7 +1,11 @@
use crate::launcher::auth::provider::Credentials;
-use crate::launcher::meta::{Argument, ArgumentValue, Library, Os, VersionType};
use crate::launcher::rules::parse_rules;
use crate::launcher::LauncherError;
+use daedalus::get_path_from_artifact;
+use daedalus::minecraft::{Argument, ArgumentValue, Library, Os, VersionType};
+use daedalus::modded::SidedDataEntry;
+use std::collections::HashMap;
+use std::io::{BufRead, BufReader};
use std::path::Path;
use uuid::Uuid;
@@ -13,63 +17,24 @@ pub fn get_class_paths(
let mut class_paths = Vec::new();
for library in libraries {
- if library.downloads.artifact.is_some() {
- if let Some(rules) = &library.rules {
- if !super::rules::parse_rules(rules.as_slice()) {
- continue;
- }
+ if let Some(rules) = &library.rules {
+ if !super::rules::parse_rules(rules.as_slice()) {
+ continue;
}
-
- let name_items = library.name.split(':').collect::>();
-
- let package = name_items.get(0).ok_or_else(|| {
- LauncherError::ParseError(format!(
- "Unable to find package for library {}",
- &library.name
- ))
- })?;
- let name = name_items.get(1).ok_or_else(|| {
- LauncherError::ParseError(format!(
- "Unable to find name for library {}",
- &library.name
- ))
- })?;
- let version = name_items.get(2).ok_or_else(|| {
- LauncherError::ParseError(format!(
- "Unable to find version for library {}",
- &library.name
- ))
- })?;
-
- let mut path = libraries_path.to_path_buf();
-
- for directory in package.split('.') {
- path.push(directory);
- }
-
- path.push(name);
- path.push(version);
- path.push(format!("{}-{}.jar", name, version));
-
- class_paths.push(
- std::fs::canonicalize(&path)
- .map_err(|_| {
- LauncherError::InvalidInput(format!(
- "Library file at path {} does not exist",
- path.to_string_lossy()
- ))
- })?
- .to_string_lossy()
- .to_string(),
- )
}
+
+ if !library.include_in_classpath {
+ continue;
+ }
+
+ class_paths.push(get_lib_path(libraries_path, &library.name)?);
}
class_paths.push(
- std::fs::canonicalize(&client_path)
+ crate::util::absolute_path(&client_path)
.map_err(|_| {
LauncherError::InvalidInput(format!(
- "Specified client path {} does not exist",
+ "Specified class path {} does not exist",
client_path.to_string_lossy()
))
})?
@@ -83,6 +48,45 @@ pub fn get_class_paths(
}))
}
+pub fn get_class_paths_jar>(
+ libraries_path: &Path,
+ libraries: &[T],
+) -> Result {
+ let mut class_paths = Vec::new();
+
+ for library in libraries {
+ class_paths.push(get_lib_path(libraries_path, library)?)
+ }
+
+ Ok(class_paths.join(match super::download::get_os() {
+ Os::Osx | Os::Linux | Os::Unknown => ":",
+ Os::Windows => ";",
+ }))
+}
+
+pub fn get_lib_path>(libraries_path: &Path, lib: T) -> Result {
+ let mut path = libraries_path.to_path_buf();
+
+ path.push(get_path_from_artifact(lib.as_ref())?);
+
+ let path = crate::util::absolute_path(&path).map_err(|_| {
+ LauncherError::InvalidInput(format!(
+ "Library file at path {} does not exist",
+ path.to_string_lossy()
+ ))
+ })?;
+
+ /*if !path.exists() {
+ if let Some(parent) = &path.parent() {
+ std::fs::create_dir_all(parent)?;
+ }
+
+ std::fs::File::create(&path)?;
+ }*/
+
+ Ok(path.to_string_lossy().to_string())
+}
+
pub fn get_jvm_arguments(
arguments: Option<&[Argument]>,
natives_path: &Path,
@@ -97,7 +101,7 @@ pub fn get_jvm_arguments(
} else {
parsed_arguments.push(format!(
"-Djava.library.path={}",
- &*std::fs::canonicalize(natives_path)
+ &*crate::util::absolute_path(natives_path)
.map_err(|_| LauncherError::InvalidInput(format!(
"Specified natives path {} does not exist",
natives_path.to_string_lossy()
@@ -117,10 +121,12 @@ fn parse_jvm_argument(
natives_path: &Path,
class_paths: &str,
) -> Result {
+ let mut argument = argument.to_string();
+ argument.retain(|c| !c.is_whitespace());
Ok(argument
.replace(
"${natives_directory}",
- &*std::fs::canonicalize(natives_path)
+ &*crate::util::absolute_path(natives_path)
.map_err(|_| {
LauncherError::InvalidInput(format!(
"Specified natives path {} does not exist",
@@ -208,7 +214,7 @@ fn parse_minecraft_argument(
.replace("${assets_index_name}", asset_index_name)
.replace(
"${game_directory}",
- &*std::fs::canonicalize(game_directory)
+ &*crate::util::absolute_path(game_directory)
.map_err(|_| {
LauncherError::InvalidInput(format!(
"Specified game directory {} does not exist",
@@ -220,7 +226,7 @@ fn parse_minecraft_argument(
)
.replace(
"${assets_root}",
- &*std::fs::canonicalize(assets_directory)
+ &*crate::util::absolute_path(assets_directory)
.map_err(|_| {
LauncherError::InvalidInput(format!(
"Specified assets directory {} does not exist",
@@ -232,7 +238,7 @@ fn parse_minecraft_argument(
)
.replace(
"${game_assets}",
- &*std::fs::canonicalize(assets_directory)
+ &*crate::util::absolute_path(assets_directory)
.map_err(|_| {
LauncherError::InvalidInput(format!(
"Specified assets directory {} does not exist",
@@ -281,3 +287,59 @@ where
Ok(())
}
+
+pub fn get_processor_arguments>(
+ libraries_path: &Path,
+ arguments: &[T],
+ data: &HashMap,
+) -> Result, LauncherError> {
+ let mut new_arguments = Vec::new();
+
+ for argument in arguments {
+ let trimmed_arg = &argument.as_ref()[1..argument.as_ref().len() - 1];
+ if argument.as_ref().starts_with('{') {
+ if let Some(entry) = data.get(trimmed_arg) {
+ new_arguments.push(if entry.client.starts_with('[') {
+ get_lib_path(libraries_path, &entry.client[1..entry.client.len() - 1])?
+ } else {
+ entry.client.clone()
+ })
+ }
+ } else if argument.as_ref().starts_with('[') {
+ new_arguments.push(get_lib_path(libraries_path, trimmed_arg)?)
+ } else {
+ new_arguments.push(argument.as_ref().to_string())
+ }
+ }
+
+ Ok(new_arguments)
+}
+
+pub async fn get_processor_main_class(path: String) -> Result