projects
/
minecraft_web.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1b24eca
)
Parse player list from 'list' command.
author
Greg Burri
<greg.burri@gmail.com>
Wed, 23 Jun 2021 10:38:53 +0000
(12:38 +0200)
committer
Greg Burri
<greg.burri@gmail.com>
Wed, 23 Jun 2021 10:38:53 +0000
(12:38 +0200)
backend/src/minecraft_controller.rs
patch
|
blob
|
history
diff --git
a/backend/src/minecraft_controller.rs
b/backend/src/minecraft_controller.rs
index
9bcc7d3
..
d9a68c0
100644
(file)
--- a/
backend/src/minecraft_controller.rs
+++ b/
backend/src/minecraft_controller.rs
@@
-75,12
+75,6
@@
fn format_byte_size(bytes: u64, precision: usize) -> String {
\r
const MINECRAFT_PROCESS_NAME: &str = "java";
\r
\r
\r
const MINECRAFT_PROCESS_NAME: &str = "java";
\r
\r
-#[cfg(target_os = "linux")]
\r
-const STRING_BEFORE_CHARACTER_NAME: &str = "Got character ZDOID from";
\r
-
\r
-#[cfg(target_os = "linux")]
\r
-const STRING_BEFORE_NB_OF_CONNECTIONS: &str = "Connections";
\r
-
\r
// It doesn't work for the moment, it only scan the connection event and do not treat disconnections.
\r
fn get_active_players(rcon_password: &str) -> Vec<String> {
\r
let mut client = minecraft_client_rs::Client::new("127.0.0.1:25575".to_string()).unwrap();
\r
// It doesn't work for the moment, it only scan the connection event and do not treat disconnections.
\r
fn get_active_players(rcon_password: &str) -> Vec<String> {
\r
let mut client = minecraft_client_rs::Client::new("127.0.0.1:25575".to_string()).unwrap();
\r
@@
-90,11
+84,15
@@
fn get_active_players(rcon_password: &str) -> Vec<String> {
Ok(_) => {
\r
match client.send_command("list".to_string()) {
\r
Ok(resp) => {
\r
Ok(_) => {
\r
match client.send_command("list".to_string()) {
\r
Ok(resp) => {
\r
- println!("{}", resp.body);
\r
- Vec::new()
\r
+ resp.body
\r
+ .split('\n')
\r
+ .skip(1)
\r
+ .filter(|n| !n.is_empty())
\r
+ .map(|n| n.to_string())
\r
+ .collect()
\r
},
\r
Err(_e) => {
\r
},
\r
Err(_e) => {
\r
- println!("Error
asking see
d");
\r
+ println!("Error
from 'list' comman
d");
\r
Vec::new()
\r
},
\r
}
\r
Vec::new()
\r
},
\r
}
\r