azalea_client/plugins/
pong.rs1use bevy_app::{App, Plugin};
2use bevy_ecs::prelude::*;
3
4use super::packet::{
5 config::{ConfigPingEvent, SendConfigPacketEvent},
6 game::PingEvent,
7};
8use crate::packet::game::SendPacketEvent;
9
10pub struct PongPlugin;
18impl Plugin for PongPlugin {
19 fn build(&self, app: &mut App) {
20 app.add_observer(reply_to_game_ping)
21 .add_observer(reply_to_config_ping);
22 }
23}
24
25pub fn reply_to_game_ping(trigger: Trigger<PingEvent>, mut commands: Commands) {
26 commands.trigger(SendPacketEvent::new(
27 trigger.entity(),
28 azalea_protocol::packets::game::ServerboundPong { id: trigger.0.id },
29 ));
30}
31
32pub fn reply_to_config_ping(trigger: Trigger<ConfigPingEvent>, mut commands: Commands) {
33 commands.trigger(SendConfigPacketEvent::new(
34 trigger.entity(),
35 azalea_protocol::packets::config::ServerboundPong { id: trigger.0.id },
36 ));
37}