use crate::command::enums::bossbar_color::BossbarColor;
use crate::command::enums::bossbar_get_type::BossbarGetType;
use crate::command::enums::bossbar_style::BossbarStyle;
use crate::entity_selector::EntitySelector;
use crate::resource_location::ResourceLocation;
use crate::snbt::SNBT;
use minecraft_command_types_derive::HasMacro;
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
pub enum BossbarSetType {
Color(BossbarColor),
Max(i32),
Name(SNBT),
Players(Option<EntitySelector>),
Style(BossbarStyle),
Value(i32),
Visible(bool),
}
impl Display for BossbarSetType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
BossbarSetType::Color(color) => write!(f, "color {}", color),
BossbarSetType::Max(max) => write!(f, "max {}", max),
BossbarSetType::Name(name) => write!(f, "name {}", name),
BossbarSetType::Players(players) => {
f.write_str("players")?;
if let Some(players) = players {
write!(f, " {}", players)?;
}
Ok(())
}
BossbarSetType::Style(style) => write!(f, "style {}", style),
BossbarSetType::Value(value) => write!(f, "value {}", value),
BossbarSetType::Visible(visible) => write!(f, "visible {}", visible),
}
}
}
#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
pub enum BossbarCommand {
Add(ResourceLocation, SNBT),
Get(ResourceLocation, BossbarGetType),
List,
Remove(ResourceLocation),
Set(ResourceLocation, BossbarSetType),
}
impl Display for BossbarCommand {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
BossbarCommand::Add(id, name) => write!(f, "add {} {}", id, name),
BossbarCommand::Get(id, type_) => write!(f, "get {} {}", id, type_),
BossbarCommand::List => f.write_str("list"),
BossbarCommand::Remove(id) => write!(f, "remove {}", id),
BossbarCommand::Set(id, set_type) => write!(f, "set {} {}", id, set_type),
}
}
}