aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/plugins/brand.rs
blob: b8fa0efe6523916e37dc97d710f32db60c18ea41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use azalea_buf::AzBuf;
use azalea_protocol::packets::config::s_custom_payload::ServerboundCustomPayload;
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;

use super::packet::config::SendConfigPacketEvent;
use crate::{client_information::send_client_information, packet::login::InLoginState};

/// Send a [`ServerboundCustomPayload`] with "vanilla" as the brand on join.
///
/// You can [disable this plugin](https://azalea.matdoes.dev/azalea/struct.ClientBuilder.html#method.new_without_plugins)
/// and register your own system if you'd like to send a different brand.
pub struct BrandPlugin;
impl Plugin for BrandPlugin {
    fn build(&self, app: &mut App) {
        app.add_systems(Update, send_brand.before(send_client_information));
    }
}

pub fn send_brand(mut commands: Commands, mut removed: RemovedComponents<InLoginState>) {
    for entity in removed.read() {
        let mut brand_data = Vec::new();
        // pretend to be vanilla
        "vanilla".to_owned().azalea_write(&mut brand_data).unwrap();
        commands.trigger(SendConfigPacketEvent::new(
            entity,
            ServerboundCustomPayload {
                identifier: "brand".into(),
                data: brand_data.into(),
            },
        ));
    }
}