From 7bdcc28b658b3aa6ac2b3244965c9b90f7e1a439 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 6 Jul 2022 01:55:00 -0700 Subject: [PATCH] Expose the send_packet fn when 'protocol' feature is active --- src/client.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index d0fd2e7..99a8de4 100644 --- a/src/client.rs +++ b/src/client.rs @@ -160,7 +160,7 @@ pub(crate) struct ClientFlags { got_keepalive: bool, hardcore: bool, #[bits(7)] - _pad: u8 + _pad: u8, } impl Client { @@ -233,6 +233,8 @@ impl Client { /// Sends a system message to the player. pub fn send_message(&mut self, msg: impl Into) { + // We buffer messages because weird things happen if we send them before the + // login packet. self.msgs_to_send.push(msg.into()); } @@ -410,6 +412,12 @@ impl Client { /// Attempts to enqueue a play packet to be sent to this client. The client /// is disconnected if the clientbound packet buffer is full. + #[cfg(feature = "protocol")] + pub fn send_packet(&mut self, packet: impl Into) { + send_packet(&mut self.send, packet); + } + + #[cfg(not(feature = "protocol"))] pub(crate) fn send_packet(&mut self, packet: impl Into) { send_packet(&mut self.send, packet); }