minecraft_command_types/command/
stopwatch.rs

1use crate::resource_location::ResourceLocation;
2use minecraft_command_types_derive::HasMacro;
3use ordered_float::NotNan;
4use std::fmt::{Display, Formatter};
5
6#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
7pub enum StopwatchCommand {
8    Create(ResourceLocation),
9    Query(ResourceLocation, Option<NotNan<f32>>),
10    Restart(ResourceLocation),
11    Remove(ResourceLocation),
12}
13
14impl Display for StopwatchCommand {
15    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
16        match self {
17            StopwatchCommand::Create(location) => {
18                write!(f, "create {}", location)
19            }
20            StopwatchCommand::Query(location, scale) => {
21                write!(f, "query {}", location)?;
22
23                if let Some(scale) = scale {
24                    write!(f, " {}", scale)?;
25                }
26
27                Ok(())
28            }
29            StopwatchCommand::Restart(location) => {
30                write!(f, "restart {}", location)
31            }
32            StopwatchCommand::Remove(location) => {
33                write!(f, "remove {}", location)
34            }
35        }
36    }
37}