Get the version from the process command line (WIP)
[minecraft_web.git] / backend / src / minecraft_controller.rs
index 54143e8..be58549 100644 (file)
@@ -9,6 +9,7 @@ pub struct MinecraftExe {
     uptime: u64, // [s].\r
     world_size: u64, // [B].\r
     active_players: Vec<String>,\r
+    version: String,\r
     last_backup: Option<SystemTime>,\r
 }\r
 \r
@@ -40,6 +41,10 @@ impl MinecraftExe {
         }\r
     }\r
 \r
+    pub fn format_version(&self) -> String {\r
+        self.version.clone()\r
+    }\r
+\r
     pub fn format_last_backup(&self) -> String {\r
         match self.last_backup {\r
             Some(t) => {\r
@@ -72,7 +77,7 @@ fn format_byte_size(bytes: u64, precision: usize) -> String {
 const MINECRAFT_PROCESS_NAME: &str = "java";\r
 \r
 struct StatusFromRcon {\r
-    players: Vec<String>,\r
+    players: Vec<String>\r
 }\r
 \r
 fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon {\r
@@ -145,6 +150,7 @@ pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str,
                 uptime: std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() - process.start_time(),\r
                 world_size,\r
                 active_players: status_from_rcon.players,\r
+                version: process.cmd()[process.cmd().len() - 2].clone(), // TODO: Extract the version from the .jar filename.\r
                 last_backup: get_last_backup_datetime(backup_path)\r
             }\r
         )\r