Skip to main content

azalea_chat/component/
score.rs

1use azalea_codec::{Codec, types::Drain};
2
3use crate::component::{base::BaseComponent, text::TextComponent};
4
5#[derive(Clone, Debug, PartialEq, Codec)]
6pub struct ScoreComponent {
7    pub score: ScoreInner,
8    #[codec(flatten)]
9    pub base: BaseComponent,
10}
11
12#[derive(Clone, Debug, PartialEq, Codec)]
13pub struct ScoreInner {
14    pub name: ScoreName,
15    pub objective: String,
16}
17
18#[derive(Clone, Debug, PartialEq, Codec)]
19pub enum ScoreName {
20    String(String),
21    // TODO: EntitySelector.COMPILABLE_CODEC
22    EntitySelector(Drain),
23}
24
25impl ScoreComponent {
26    pub fn into_text_component(self) -> TextComponent {
27        TextComponent::default().with_base(self.base)
28    }
29}