Skip to content

Commit 313503c

Browse files
feat: Make server ping response data a resource (#948)
🤷‍♂️ --------- Co-authored-by: TestingPlant <[email protected]>
1 parent 1f28877 commit 313503c

File tree

1 file changed

+22
-2
lines changed
  • crates/hyperion/src/ingress

1 file changed

+22
-2
lines changed

crates/hyperion/src/ingress/mod.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,27 @@ pub fn process_handshake(
6666
}
6767
}
6868

69+
#[derive(Resource)]
70+
pub struct ServerPingResponse {
71+
pub description: String,
72+
pub max_players: u32,
73+
}
74+
75+
impl Default for ServerPingResponse {
76+
fn default() -> Self {
77+
Self {
78+
description: String::from(
79+
"Getting 10k Players to PvP at Once on a Minecraft Server to Break the Guinness \
80+
World Record",
81+
),
82+
max_players: 12_000,
83+
}
84+
}
85+
}
86+
6987
fn process_status_request(
7088
mut packets: EventReader<'_, '_, packet::status::QueryRequest>,
89+
ping_response_data: Res<'_, ServerPingResponse>,
7190
compose: Res<'_, Compose>,
7291
) {
7392
for packet in packets.read() {
@@ -89,10 +108,10 @@ fn process_status_request(
89108
},
90109
"players": {
91110
"online": online,
92-
"max": 12_000,
111+
"max": ping_response_data.max_players,
93112
"sample": [],
94113
},
95-
"description": "Getting 10k Players to PvP at Once on a Minecraft Server to Break the Guinness World Record",
114+
"description": ping_response_data.description,
96115
// "favicon": favicon,
97116
});
98117

@@ -288,5 +307,6 @@ impl Plugin for IngressPlugin {
288307
),
289308
);
290309
app.add_observer(remove_player_from_visibility);
310+
app.init_resource::<ServerPingResponse>();
291311
}
292312
}

0 commit comments

Comments
 (0)