Skip to main content

steel_protocol/packets/status/
c_status_response.rs

1use serde::Serialize;
2use steel_macros::{ClientPacket, WriteTo};
3use steel_registry::packets::status::C_STATUS_RESPONSE;
4
5#[derive(Serialize, Clone, Debug)]
6pub struct Sample {
7    /// The player's name.
8    pub name: String,
9    /// The player's UUID.
10    pub id: String,
11}
12
13#[derive(Clone, Debug, Serialize)]
14pub struct Players {
15    pub max: i32,
16    pub online: i32,
17    pub sample: Vec<Sample>,
18}
19
20#[derive(Clone, Debug, Serialize)]
21pub struct Version {
22    pub name: &'static str,
23    pub protocol: i32,
24}
25
26#[derive(Clone, Debug, Serialize)]
27pub struct Status {
28    pub description: String,
29    pub players: Option<Players>,
30    pub version: Option<Version>,
31    pub favicon: Option<String>,
32    pub enforce_secure_chat: bool,
33}
34
35#[derive(ClientPacket, WriteTo, Clone, Debug)]
36#[packet_id(Status = C_STATUS_RESPONSE)]
37pub struct CStatusResponse {
38    #[write(as = Json)]
39    status: Status,
40}
41
42impl CStatusResponse {
43    #[must_use]
44    pub const fn new(status: Status) -> Self {
45        Self { status }
46    }
47}