Add new SystemChatMessage and handle in server

This commit is contained in:
ice_iix 2022-08-07 18:19:09 -07:00
parent dfa6fa34b5
commit 4eea97520c
3 changed files with 17 additions and 1 deletions

View File

@ -911,6 +911,13 @@ state_packets!(
field nodes: LenPrefixed<VarInt, packet::CommandNode> =,
field root_index: VarInt =,
}
/// SystemChatMessage is sent by the server for system messages, the system/chat
/// distinction exists to respect the user's chat visibility settings.
packet SystemChatMessage {
field message: format::Component =,
/// Whether the message is an actionbar or chat message
field overlay: bool =,
}
/// ServerMessage is a message sent by the server. It could be from a player
/// or just a system message. The Type field controls the location the
/// message is displayed at and when the message is displayed.

View File

@ -155,7 +155,7 @@ protocol_packet_ids!(
0x5c => EntitySoundEffect
0x5d => SoundEffect
0x5e => StopSound
//0x5f => SystemChatMessage // TODO
0x5f => SystemChatMessage
0x60 => PlayerListHeaderFooter
0x61 => NBTQueryResponse
0x62 => CollectItem

View File

@ -680,6 +680,7 @@ impl Server {
UpdateSign_u16 => on_sign_update_u16,
PlayerInfo => on_player_info,
PlayerInfo_String => on_player_info_string,
SystemChatMessage => on_system_chat_message,
ServerMessage_NoPosition => on_servermessage_noposition,
ServerMessage_Position => on_servermessage_position,
ServerMessage_Sender => on_servermessage_sender,
@ -1996,6 +1997,14 @@ impl Server {
}
}
fn on_system_chat_message(
&mut self,
m: packet::play::clientbound::SystemChatMessage,
) {
// TODO: flag as system message (vs chat message)
self.on_servermessage(&m.message, None, None);
}
fn on_servermessage_noposition(
&mut self,
m: packet::play::clientbound::ServerMessage_NoPosition,