minecraft_command_types/command/
time.rs1use crate::command::enums::time_of_day::TimeOfDay;
2use crate::command::enums::time_query_type::TimeQueryType;
3use crate::time::Time;
4use minecraft_command_types_derive::HasMacro;
5use std::fmt::{Display, Formatter};
6
7#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
8pub enum TimeSetType {
9 Time(Time),
10 TimeOfDay(TimeOfDay),
11}
12
13impl Display for TimeSetType {
14 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15 match self {
16 TimeSetType::Time(time) => time.fmt(f),
17 TimeSetType::TimeOfDay(time_of_day) => time_of_day.fmt(f),
18 }
19 }
20}
21
22#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
23pub enum TimeCommand {
24 Add(Time),
25 Query(TimeQueryType),
26 Set(TimeSetType),
27}
28
29impl Display for TimeCommand {
30 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
31 match self {
32 TimeCommand::Add(time) => write!(f, "add {}", time),
33 TimeCommand::Query(query_type) => write!(f, "query {}", query_type),
34 TimeCommand::Set(set_type) => write!(f, "set {}", set_type),
35 }
36 }
37}