Pumpkin/pumpkin-text/src/hover.rs
Snowiiii a6d9ed216d Use Cow's in TextComponent
We now don't always convert &str to Strings allowing us to use stack allocations
2024-08-19 20:05:18 +02:00

35 lines
1.0 KiB
Rust

use std::borrow::Cow;
use serde::{Deserialize, Serialize};
use crate::Text;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "action", content = "contents", rename_all = "snake_case")]
#[allow(clippy::enum_variant_names)]
pub enum HoverEvent<'a> {
/// Displays a tooltip with the given text.
ShowText(Text<'a>),
/// Shows an item.
ShowItem {
/// Resource identifier of the item
id: Cow<'a, str>,
/// Number of the items in the stack
count: Option<i32>,
/// NBT information about the item (sNBT format)
tag: Cow<'a, str>,
},
/// Shows an entity.
ShowEntity {
/// The entity's UUID
id: uuid::Uuid,
/// Resource identifier of the entity
#[serde(rename = "type")]
#[serde(default, skip_serializing_if = "Option::is_none")]
kind: Option<Cow<'a, str>>,
/// Optional custom name for the entity
#[serde(default, skip_serializing_if = "Option::is_none")]
name: Option<Text<'a>>,
},
}