Renamed command event

This commit is contained in:
Joshua Barretto 2021-06-18 11:31:06 +01:00
parent 0067cea560
commit 294b6e394a
4 changed files with 8 additions and 8 deletions

View File

@ -140,7 +140,7 @@ pub enum ServerEvent {
ClientDisconnect(EcsEntity, DisconnectReason), ClientDisconnect(EcsEntity, DisconnectReason),
ClientDisconnectWithoutPersistence(EcsEntity), ClientDisconnectWithoutPersistence(EcsEntity),
ChunkRequest(EcsEntity, Vec2<i32>), ChunkRequest(EcsEntity, Vec2<i32>),
ChatCmd(EcsEntity, String, Vec<String>), Command(EcsEntity, String, Vec<String>),
/// Send a chat message to the player from an npc or other player /// Send a chat message to the player from an npc or other player
Chat(comp::UnresolvedChatMsg), Chat(comp::UnresolvedChatMsg),
Aura { Aura {

View File

@ -51,7 +51,7 @@ impl Server {
let mut frontend_events = Vec::new(); let mut frontend_events = Vec::new();
let mut requested_chunks = Vec::new(); let mut requested_chunks = Vec::new();
let mut chat_commands = Vec::new(); let mut commands = Vec::new();
let mut chat_messages = Vec::new(); let mut chat_messages = Vec::new();
let events = self let events = self
@ -188,8 +188,8 @@ impl Server {
ServerEvent::ChunkRequest(entity, key) => { ServerEvent::ChunkRequest(entity, key) => {
requested_chunks.push((entity, key)); requested_chunks.push((entity, key));
}, },
ServerEvent::ChatCmd(entity, name, args) => { ServerEvent::Command(entity, name, args) => {
chat_commands.push((entity, name, args)); commands.push((entity, name, args));
}, },
ServerEvent::Chat(msg) => { ServerEvent::Chat(msg) => {
chat_messages.push(msg); chat_messages.push(msg);
@ -229,8 +229,8 @@ impl Server {
self.generate_chunk(entity, key); self.generate_chunk(entity, key);
} }
for (entity, name, args) in chat_commands { for (entity, name, args) in commands {
self.process_chat_cmd(entity, name, args); self.process_command(entity, name, args);
} }
for msg in chat_messages { for msg in chat_messages {

View File

@ -983,7 +983,7 @@ impl Server {
); );
} }
fn process_chat_cmd(&mut self, entity: EcsEntity, name: String, args: Vec<String>) { fn process_command(&mut self, entity: EcsEntity, name: String, args: Vec<String>) {
// Find the command object and run its handler. // Find the command object and run its handler.
if let Ok(command) = name.parse::<ChatCommand>() { if let Ok(command) = name.parse::<ChatCommand>() {
command.execute(self, entity, args); command.execute(self, entity, args);

View File

@ -49,7 +49,7 @@ impl Sys {
}, },
ClientGeneral::Command(name, args) => { ClientGeneral::Command(name, args) => {
if player.is_some() { if player.is_some() {
server_emitter.emit(ServerEvent::ChatCmd(entity, name, args)); server_emitter.emit(ServerEvent::Command(entity, name, args));
} }
}, },
ClientGeneral::Terminate => { ClientGeneral::Terminate => {