X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fminecraft_controller.rs;h=7af13dd9a4b02b73a383f813180fde1ffa6ef406;hb=56bda46ddd9202d7d5485792fc2062fc69b6ed07;hp=163008a0f439810ac2192975a3dfa003f1726c0e;hpb=7d3366c4902d5c3e91551668e92d4572f9634511;p=minecraft_web.git diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index 163008a..7af13dd 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -86,14 +86,16 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { StatusFromRcon { players: match client.send_command("list".to_string()) { - Ok(resp) => { - resp.body - .split('\n') - .skip(1) - .filter(|n| !n.is_empty()) - .map(|n| n.to_string()) - .collect() - }, + Ok(resp) => + match resp.body.find(':') { + Some(i) if i < resp.body.len() -1 => + resp.body[i + 1..resp.body.len()] + .split(',') + .map(|nick| nick.trim().to_string()) + .filter(|nick| !nick.is_empty()) + .collect(), + _ => Vec::new() + }, Err(_e) => { println!("Error from 'list' command"); Vec::new() @@ -142,7 +144,7 @@ pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str, Some( MinecraftExe { - memory: process.memory(), + memory: process.memory() / 3, // Because the Java garbage collector ZGC reports three times more the real memory usage: https://stackoverflow.com/a/62934057/212675 load_average_5min: system.get_load_average().five / system.get_processors().len() as f64 * 100., uptime: std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() - process.start_time(), world_size,