pub enum ChatPacket {
System(Arc<ClientboundSystemChatPacket>),
Player(Arc<ClientboundPlayerChatPacket>),
Disguised(Arc<ClientboundDisguisedChatPacket>),
}
Expand description
A chat packet, either a system message or a chat message.
Variants§
System(Arc<ClientboundSystemChatPacket>)
Player(Arc<ClientboundPlayerChatPacket>)
Disguised(Arc<ClientboundDisguisedChatPacket>)
Implementations§
Source§impl ChatPacket
impl ChatPacket
Sourcepub fn message(&self) -> FormattedText
pub fn message(&self) -> FormattedText
Get the message shown in chat for this packet.
Sourcepub fn split_sender_and_content(&self) -> (Option<String>, String)
pub fn split_sender_and_content(&self) -> (Option<String>, String)
Determine the username of the sender and content of the message. This does not preserve formatting codes. If it’s not a player-sent chat message or the sender couldn’t be determined, the username part will be None.
Sourcepub fn username(&self) -> Option<String>
pub fn username(&self) -> Option<String>
Get the username of the sender of the message. If it’s not a player-sent chat message or the sender couldn’t be determined, this will be None.
Sourcepub fn uuid(&self) -> Option<Uuid>
pub fn uuid(&self) -> Option<Uuid>
Get the UUID of the sender of the message. If it’s not a player-sent chat message, this will be None (this is sometimes the case when a server uses a plugin to modify chat messages).
Sourcepub fn content(&self) -> String
pub fn content(&self) -> String
Get the content part of the message as a string. This does not preserve formatting codes. If it’s not a player-sent chat message or the sender couldn’t be determined, this will contain the entire message.
Sourcepub fn new(message: &str) -> ChatPacket
pub fn new(message: &str) -> ChatPacket
Create a new ChatPacket from a string. This is meant to be used as a convenience function for testing.
Sourcepub fn is_whisper(&self) -> bool
pub fn is_whisper(&self) -> bool
Whether this message was sent with /msg (or aliases). It works by checking the translation key, so it won’t work on servers that use their own whisper system.
Trait Implementations§
Source§impl Clone for ChatPacket
impl Clone for ChatPacket
Source§fn clone(&self) -> ChatPacket
fn clone(&self) -> ChatPacket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ChatPacket
impl Debug for ChatPacket
Source§impl PartialEq for ChatPacket
impl PartialEq for ChatPacket
impl StructuralPartialEq for ChatPacket
Auto Trait Implementations§
impl Freeze for ChatPacket
impl RefUnwindSafe for ChatPacket
impl Send for ChatPacket
impl Sync for ChatPacket
impl Unpin for ChatPacket
impl UnwindSafe for ChatPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.