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

Commit d5faebc

Browse files
committed
update chat
1 parent c33edcc commit d5faebc

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/client/processor.rs

+22-19
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,34 @@ impl<'a, I: InterfaceOut> SimpleInterfaceIn<'a, I> {
5757
}
5858
}
5959

60+
impl<'a, I: InterfaceOut> SimpleInterfaceIn<'a, I> {
61+
pub fn process_player_message(&mut self, msg: PlayerMessage) {
62+
println!("processing player message {msg:?}");
63+
if let Some(cmd) = msg.into_cmd() {
64+
let name = cmd.command;
65+
let args_str: Vec<&str> = cmd.args.iter().map(String::as_str).collect();
66+
if let Err(err) = process_command(
67+
&name,
68+
&args_str,
69+
self.local,
70+
self.global,
71+
self.actions,
72+
self.out,
73+
) {
74+
println!("could not process command. Reason: {err:?}");
75+
}
76+
}
77+
}
78+
}
79+
6080
impl<'a, I: InterfaceOut> InterfaceIn for SimpleInterfaceIn<'a, I> {
6181
fn on_chat(&mut self, message: Chat) {
6282
println!("{}", message.clone().colorize());
6383

64-
let mut process = |msg: PlayerMessage| {
65-
if let Some(cmd) = msg.into_cmd() {
66-
let name = cmd.command;
67-
let args_str: Vec<&str> = cmd.args.iter().map(String::as_str).collect();
68-
if let Err(err) = process_command(
69-
&name,
70-
&args_str,
71-
self.local,
72-
self.global,
73-
self.actions,
74-
self.out,
75-
) {
76-
println!("could not process command. Reason: {err:?}");
77-
}
78-
}
79-
};
80-
8184
if let Some(msg) = message.player_message() {
82-
process(msg);
85+
self.process_player_message(msg);
8386
} else if let Some(msg) = message.player_dm() {
84-
process(msg);
87+
self.process_player_message(msg);
8588
}
8689
}
8790

src/protocol/v340/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ impl EventQueue for EventQueue340 {
6464
}
6565

6666
impl EventQueue340 {
67+
// allow lines
68+
#[allow(clippy::too_many_lines)]
6769
fn process_packet(&mut self, mut data: PacketData, processor: &mut impl InterfaceIn) {
6870
use clientbound::*;
6971
match data.id {

0 commit comments

Comments
 (0)