aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Wandzio <contact@philw.dev>2026-02-03 16:34:38 +0100
committerFilip Wandzio <contact@philw.dev>2026-02-03 16:34:38 +0100
commitc97d9c3b01133493b30baeec912c496867873dc5 (patch)
treef0f06bb55c88de4ba6d9c09179ee1822e8fdf78f /src
parenta393e0a2f2c3678a3ea869dc1417fa269f2b1040 (diff)
downloaddml-c97d9c3b01133493b30baeec912c496867873dc5.tar.gz
dml-c97d9c3b01133493b30baeec912c496867873dc5.zip
Purge leftover comments
Diffstat (limited to '')
-rw-r--r--src/minecraft/downloads.rs15
-rw-r--r--src/minecraft/launcher.rs9
2 files changed, 2 insertions, 22 deletions
diff --git a/src/minecraft/downloads.rs b/src/minecraft/downloads.rs
index a994146..7017d3f 100644
--- a/src/minecraft/downloads.rs
+++ b/src/minecraft/downloads.rs
@@ -16,7 +16,7 @@ use crate::{
16#[derive(Debug, Deserialize)] 16#[derive(Debug, Deserialize)]
17struct AssetObject { 17struct AssetObject {
18 hash: String, 18 hash: String,
19 size: u64, 19 // size: u64,
20} 20}
21 21
22#[derive(Debug, Deserialize)] 22#[derive(Debug, Deserialize)]
@@ -24,10 +24,6 @@ struct AssetIndexManifest {
24 objects: std::collections::HashMap<String, AssetObject>, 24 objects: std::collections::HashMap<String, AssetObject>,
25} 25}
26 26
27/// Pobiera wszystko potrzebne do uruchomienia Minecraft:
28/// - client jar
29/// - biblioteki (artifact + natives)
30/// - assets (w tym textures, sounds)
31pub async fn download_all( 27pub async fn download_all(
32 config: &Config, 28 config: &Config,
33 version: &Version, 29 version: &Version,
@@ -58,7 +54,6 @@ async fn download_libraries(
58 libraries: &[Library], 54 libraries: &[Library],
59) -> Result<(), McError> { 55) -> Result<(), McError> {
60 for library in libraries { 56 for library in libraries {
61 // ===== CLASSPATH LIBRARIES =====
62 if let Some(artifact) = &library.downloads.artifact { 57 if let Some(artifact) = &library.downloads.artifact {
63 let library_path = paths::library_file(config, &artifact.path)?; 58 let library_path = paths::library_file(config, &artifact.path)?;
64 59
@@ -68,7 +63,6 @@ async fn download_libraries(
68 } 63 }
69 } 64 }
70 65
71 // ===== NATIVES =====
72 if let Some(classifiers) = &library.downloads.classifiers { 66 if let Some(classifiers) = &library.downloads.classifiers {
73 for (_, native) in classifiers { 67 for (_, native) in classifiers {
74 let native_path = paths::library_file(config, &native.path)?; 68 let native_path = paths::library_file(config, &native.path)?;
@@ -97,7 +91,6 @@ async fn download_asset_index(
97 McError::Config("Missing asset_index in version.json".into()) 91 McError::Config("Missing asset_index in version.json".into())
98 })?; 92 })?;
99 93
100 // Nie pozwalamy na legacy dla nowoczesnych wersji
101 if asset_index.id == "legacy" { 94 if asset_index.id == "legacy" {
102 return Err(McError::Config( 95 return Err(McError::Config(
103 "Legacy assetIndex detected – pobierz właściwy version.json".into(), 96 "Legacy assetIndex detected – pobierz właściwy version.json".into(),
@@ -108,14 +101,12 @@ async fn download_asset_index(
108 .join("indexes") 101 .join("indexes")
109 .join(format!("{}.json", asset_index.id)); 102 .join(format!("{}.json", asset_index.id));
110 103
111 // Jeśli indeks istnieje lokalnie
112 if index_path.exists() { 104 if index_path.exists() {
113 let index_data = fs::read_to_string(&index_path).await?; 105 let index_data = fs::read_to_string(&index_path).await?;
114 let manifest: AssetIndexManifest = serde_json::from_str(&index_data)?; 106 let manifest: AssetIndexManifest = serde_json::from_str(&index_data)?;
115 return Ok(manifest); 107 return Ok(manifest);
116 } 108 }
117 109
118 // Pobierz indeks z sieci
119 info!("Downloading asset index {}", asset_index.id); 110 info!("Downloading asset index {}", asset_index.id);
120 let response = get(&asset_index.url).await?; 111 let response = get(&asset_index.url).await?;
121 let manifest_text = response.text().await?; 112 let manifest_text = response.text().await?;
@@ -132,13 +123,11 @@ async fn download_assets(
132) -> Result<(), McError> { 123) -> Result<(), McError> {
133 let assets_dir = paths::assets_dir(config); 124 let assets_dir = paths::assets_dir(config);
134 125
135 // Katalogi MUSZĄ istnieć
136 create_dir_all(assets_dir.join("objects")).await?; 126 create_dir_all(assets_dir.join("objects")).await?;
137 create_dir_all(assets_dir.join("indexes")).await?; 127 create_dir_all(assets_dir.join("indexes")).await?;
138 128
139 let manifest = download_asset_index(config, version).await?; 129 let manifest = download_asset_index(config, version).await?;
140 130
141 // Pobieramy wszystkie obiekty
142 for (logical_path, asset) in &manifest.objects { 131 for (logical_path, asset) in &manifest.objects {
143 let subdir = &asset.hash[0..2]; 132 let subdir = &asset.hash[0..2];
144 let file_path = assets_dir 133 let file_path = assets_dir
@@ -158,7 +147,6 @@ async fn download_assets(
158 download_file(&url, &file_path).await?; 147 download_file(&url, &file_path).await?;
159 } 148 }
160 149
161 // Pobierz sounds.json jeśli istnieje
162 if let Some(asset) = manifest.objects.get("sounds.json") { 150 if let Some(asset) = manifest.objects.get("sounds.json") {
163 let file_path = assets_dir.join("indexes").join("sounds.json"); 151 let file_path = assets_dir.join("indexes").join("sounds.json");
164 if !file_path.exists() { 152 if !file_path.exists() {
@@ -175,7 +163,6 @@ async fn download_assets(
175 Ok(()) 163 Ok(())
176} 164}
177 165
178/// Helper do pobierania plików
179async fn download_file( 166async fn download_file(
180 url: &str, 167 url: &str,
181 path: &std::path::Path, 168 path: &std::path::Path,
diff --git a/src/minecraft/launcher.rs b/src/minecraft/launcher.rs
index cfd6c85..2eeaf21 100644
--- a/src/minecraft/launcher.rs
+++ b/src/minecraft/launcher.rs
@@ -9,7 +9,6 @@ use crate::{
9 platform::paths, 9 platform::paths,
10}; 10};
11 11
12/// Buduje classpath dla danej wersji Minecrafta
13fn build_classpath( 12fn build_classpath(
14 config: &Config, 13 config: &Config,
15 version: &Version, 14 version: &Version,
@@ -27,14 +26,12 @@ fn build_classpath(
27 } 26 }
28 } 27 }
29 28
30 // client.jar zawsze na końcu classpath
31 let client_jar = paths::client_jar(config, &version.id)?; 29 let client_jar = paths::client_jar(config, &version.id)?;
32 entries.push(client_jar.to_string_lossy().to_string()); 30 entries.push(client_jar.to_string_lossy().to_string());
33 31
34 Ok(entries.join(sep)) 32 Ok(entries.join(sep))
35} 33}
36 34
37/// Uruchamia Minecraft
38pub fn launch(config: &Config, version: &Version) -> Result<(), McError> { 35pub fn launch(config: &Config, version: &Version) -> Result<(), McError> {
39 let java = &config.java_path; 36 let java = &config.java_path;
40 let classpath = build_classpath(config, version)?; 37 let classpath = build_classpath(config, version)?;
@@ -63,7 +60,6 @@ pub fn launch(config: &Config, version: &Version) -> Result<(), McError> {
63 60
64 let mut cmd = Command::new(java); 61 let mut cmd = Command::new(java);
65 62
66 // ===== JVM ARGUMENTS (muszą być na początku) =====
67 cmd.arg(format!("-Xmx{}M", config.max_memory_mb)) 63 cmd.arg(format!("-Xmx{}M", config.max_memory_mb))
68 .arg(format!("-Djava.library.path={}", natives_dir.display())); 64 .arg(format!("-Djava.library.path={}", natives_dir.display()));
69 65
@@ -71,12 +67,10 @@ pub fn launch(config: &Config, version: &Version) -> Result<(), McError> {
71 cmd.arg(arg); 67 cmd.arg(arg);
72 } 68 }
73 69
74 // ===== CLASSPATH + MAIN CLASS =====
75 cmd.arg("-cp") 70 cmd.arg("-cp")
76 .arg(classpath) 71 .arg(classpath)
77 .arg(&version.main_class); 72 .arg(&version.main_class);
78 73
79 // ===== ARGUMENTY GRY =====
80 cmd.arg("--username") 74 cmd.arg("--username")
81 .arg(&config.username) 75 .arg(&config.username)
82 .arg("--version") 76 .arg("--version")
@@ -94,7 +88,7 @@ pub fn launch(config: &Config, version: &Version) -> Result<(), McError> {
94 .arg("--accessToken") 88 .arg("--accessToken")
95 .arg("0") 89 .arg("0")
96 .arg("--userType") 90 .arg("--userType")
97 .arg("legacy"); // legacy dla starych kont, można później zmienić 91 .arg("legacy");
98 92
99 let status = cmd.status()?; 93 let status = cmd.status()?;
100 94
@@ -105,7 +99,6 @@ pub fn launch(config: &Config, version: &Version) -> Result<(), McError> {
105 Ok(()) 99 Ok(())
106} 100}
107 101
108/// Sprawdza reguły bibliotek tak jak robi Mojang
109fn library_allowed(lib: &Library) -> bool { 102fn library_allowed(lib: &Library) -> bool {
110 let rules = match &lib.rules { 103 let rules = match &lib.rules {
111 | Some(r) => r, 104 | Some(r) => r,