minecraft_command_types/command/
waypoint.rs1use crate::command::enums::team_color_with_reset::TeamColorWithReset;
2use crate::entity_selector::EntitySelector;
3use crate::resource_location::ResourceLocation;
4use minecraft_command_types_derive::HasMacro;
5use std::fmt::{Display, Formatter};
6
7#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
8pub enum WaypointColor {
9 Color(TeamColorWithReset),
10 Hex(String),
11 Reset,
12}
13
14impl Display for WaypointColor {
15 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
16 match self {
17 WaypointColor::Color(color) => color.fmt(f),
18 WaypointColor::Hex(hex) => write!(f, "hex {}", hex),
19 WaypointColor::Reset => f.write_str("reset"),
20 }
21 }
22}
23
24#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
25pub enum WaypointStyleModification {
26 Set(ResourceLocation),
27 Reset,
28}
29
30impl Display for WaypointStyleModification {
31 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
32 match self {
33 WaypointStyleModification::Set(style) => write!(f, "set {}", style),
34 WaypointStyleModification::Reset => f.write_str("reset"),
35 }
36 }
37}
38
39#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
40pub enum WaypointModification {
41 Color(WaypointColor),
42 Style(WaypointStyleModification),
43}
44
45impl Display for WaypointModification {
46 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
47 match self {
48 WaypointModification::Color(color) => write!(f, "color {}", color),
49 WaypointModification::Style(style) => write!(f, "style {}", style),
50 }
51 }
52}
53
54#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
55pub enum WaypointCommand {
56 List,
57 Modify(EntitySelector, WaypointModification),
58}
59
60impl Display for WaypointCommand {
61 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
62 match self {
63 WaypointCommand::List => f.write_str("list"),
64 WaypointCommand::Modify(selector, modification) => {
65 write!(f, "modify {} {}", selector, modification)
66 }
67 }
68 }
69}