say command + playerlist works now

This commit is contained in:
Luuk van Oijen
2023-11-24 14:37:07 +01:00
parent 145b74aefc
commit b06d2fe151
4 changed files with 45 additions and 10 deletions

View File

@@ -73,7 +73,7 @@ fn load_plugins(server_resource_folder: String) -> Vec<Plugin> {
plugins
}
#[derive(PartialEq, Eq, Clone, Debug)]
#[derive(PartialEq, Eq, Clone, Debug, Default)]
pub struct ServerStatus {
pub player_count: usize,
pub player_list: Vec<(u8, String)>,
@@ -551,6 +551,18 @@ impl Server {
Ok(())
}
pub async fn send_chat_message(&self, message: &str, target: Option<u8>) {
let packet = Packet::Raw(RawPacket::from_str(&format!("C:Server: {message}")));
if let Some(_id) = target {
// TODO: Implement this!
todo!("Sending server chat messages to specific player is not supported yet!");
// info!("[CHAT] Server @ {id}: {message}");
} else {
info!("[CHAT] Server: {message}");
self.broadcast(packet, None).await;
}
}
// NOTE: Skips all clients that are currently connecting or syncing resources!
async fn broadcast(&self, packet: Packet, owner: Option<u8>) {
for client in &self.clients {