Skip to main content

steel_protocol/packets/common/
c_disconnect.rs

1use steel_macros::{ClientPacket, WriteTo};
2use steel_registry::packets::config::C_DISCONNECT;
3use steel_registry::packets::play::C_DISCONNECT as PLAY_C_DISCONNECT;
4use text_components::TextComponent;
5use text_components::resolving::TextResolutor;
6
7#[derive(ClientPacket, WriteTo, Clone, Debug)]
8#[packet_id(Config = C_DISCONNECT, Play = PLAY_C_DISCONNECT)]
9pub struct CDisconnect {
10    pub reason: TextComponent,
11}
12
13impl CDisconnect {
14    #[must_use]
15    pub fn new<T: TextResolutor>(reason: &TextComponent, player: &T) -> Self {
16        Self {
17            reason: reason.resolve(player),
18        }
19    }
20}