Skip to content

Commit a75a346

Browse files
committed
Handle client-bound plugin message packets
1 parent e2fa4e8 commit a75a346

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/server/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ impl Server {
388388
match pck {
389389
Ok(pck) => handle_packet!{
390390
self pck {
391+
PluginMessageClientbound_i16 => on_plugin_message_clientbound_i16,
392+
PluginMessageClientbound => on_plugin_message_clientbound_1,
391393
JoinGame_i32_ViewDistance => on_game_join_i32_viewdistance,
392394
JoinGame_i32 => on_game_join_i32,
393395
JoinGame_i8 => on_game_join_i8,
@@ -667,6 +669,18 @@ impl Server {
667669
});
668670
}
669671

672+
fn on_plugin_message_clientbound_i16(&mut self, msg: packet::play::clientbound::PluginMessageClientbound_i16) {
673+
self.on_plugin_message_clientbound(&msg.channel, msg.data.data.as_slice())
674+
}
675+
676+
fn on_plugin_message_clientbound_1(&mut self, msg: packet::play::clientbound::PluginMessageClientbound) {
677+
self.on_plugin_message_clientbound(&msg.channel, &msg.data)
678+
}
679+
680+
fn on_plugin_message_clientbound(&mut self, channel: &str, data: &[u8]) {
681+
println!("Received plugin message: channel={}, data={:?}", channel, data);
682+
}
683+
670684
fn on_game_join_i32_viewdistance(&mut self, join: packet::play::clientbound::JoinGame_i32_ViewDistance) {
671685
self.on_game_join(join.gamemode, join.entity_id)
672686
}

0 commit comments

Comments
 (0)