X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fminecraft_controller.rs;h=7af13dd9a4b02b73a383f813180fde1ffa6ef406;hb=56bda46ddd9202d7d5485792fc2062fc69b6ed07;hp=a644c4db95bf7e5b616daf044bf2523ea2db1528;hpb=e4d360ba5fcd9ecd5717215403ed60ec64cd4b7b;p=minecraft_web.git diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index a644c4d..7af13dd 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -88,8 +88,13 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { match client.send_command("list".to_string()) { Ok(resp) => match resp.body.find(':') { - Some(i) => resp.body[i + 1..resp.body.len() - 1].split(',').map(|nick| nick.trim().to_string()).collect(), - None => Vec::new() + 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"); @@ -139,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,