Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
update chat
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Jul 24, 2024
1 parent c33edcc commit d5faebc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/client/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,34 @@ impl<'a, I: InterfaceOut> SimpleInterfaceIn<'a, I> {
}
}

impl<'a, I: InterfaceOut> SimpleInterfaceIn<'a, I> {
pub fn process_player_message(&mut self, msg: PlayerMessage) {
println!("processing player message {msg:?}");
if let Some(cmd) = msg.into_cmd() {
let name = cmd.command;
let args_str: Vec<&str> = cmd.args.iter().map(String::as_str).collect();
if let Err(err) = process_command(
&name,
&args_str,
self.local,
self.global,
self.actions,
self.out,
) {
println!("could not process command. Reason: {err:?}");
}
}
}
}

impl<'a, I: InterfaceOut> InterfaceIn for SimpleInterfaceIn<'a, I> {
fn on_chat(&mut self, message: Chat) {
println!("{}", message.clone().colorize());

let mut process = |msg: PlayerMessage| {
if let Some(cmd) = msg.into_cmd() {
let name = cmd.command;
let args_str: Vec<&str> = cmd.args.iter().map(String::as_str).collect();
if let Err(err) = process_command(
&name,
&args_str,
self.local,
self.global,
self.actions,
self.out,
) {
println!("could not process command. Reason: {err:?}");
}
}
};

if let Some(msg) = message.player_message() {
process(msg);
self.process_player_message(msg);
} else if let Some(msg) = message.player_dm() {
process(msg);
self.process_player_message(msg);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/protocol/v340/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ impl EventQueue for EventQueue340 {
}

impl EventQueue340 {
// allow lines
#[allow(clippy::too_many_lines)]
fn process_packet(&mut self, mut data: PacketData, processor: &mut impl InterfaceIn) {
use clientbound::*;
match data.id {
Expand Down

0 comments on commit d5faebc

Please sign in to comment.