mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Rename /who to /players and fmt
This commit is contained in:
parent
7182257214
commit
6289a097a5
@ -99,10 +99,10 @@ lazy_static! {
|
||||
handle_spawn,
|
||||
),
|
||||
ChatCommand::new(
|
||||
"who",
|
||||
"players",
|
||||
"{}",
|
||||
"/who : Show the online players list",
|
||||
handle_who
|
||||
"/players : Show the online players list",
|
||||
handle_players,
|
||||
),
|
||||
ChatCommand::new(
|
||||
"help", "", "/help: Display this message", handle_help)
|
||||
@ -291,28 +291,24 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_who(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) {
|
||||
fn handle_players(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) {
|
||||
let ecs = server.state.ecs();
|
||||
let players = ecs.read_storage::<comp::Player>();
|
||||
let count = players.join().count();
|
||||
let mut str: String = format!("Online players ({})", count);
|
||||
if count > 0 {
|
||||
str += ": ";
|
||||
let mut player_list: String = players
|
||||
.join()
|
||||
.fold(String::new(), |mut s, player| {
|
||||
s += &player.alias;
|
||||
s += ",";
|
||||
s
|
||||
});
|
||||
let mut player_list: String = players.join().fold(String::new(), |mut s, player| {
|
||||
s += &player.alias;
|
||||
s += ",";
|
||||
s
|
||||
});
|
||||
player_list.pop();
|
||||
server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(str + &player_list));
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(str + &player_list));
|
||||
} else {
|
||||
server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(str));
|
||||
server.clients.notify(entity, ServerMsg::Chat(str));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user