diff --git a/src/command/difficulty.rs b/src/command/difficulty.rs new file mode 100644 index 0000000..9a663c8 --- /dev/null +++ b/src/command/difficulty.rs @@ -0,0 +1,19 @@ +#[derive(Default)] +pub struct DifficultyCommand { + difficulty: Option +} + +impl DifficultyCommand { + pub fn difficulty(mut self, difficulty: super::Difficulty) -> Self { + self.difficulty = Some(difficulty); + self + } + + pub fn build(self) -> super::Command { + let mut s = format!("difficulty"); + if let Some(difficulty) = self.difficulty { + s.push_str(&format!(" {difficulty}")) + }; + super::Command(s) + } +} \ No newline at end of file diff --git a/src/command/mod.rs b/src/command/mod.rs index eda185e..0e64490 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -44,6 +44,24 @@ impl Display for Gamemode { } } +pub enum Difficulty { + Peaceful, + Easy, + Normal, + Hard +} + +impl Display for Difficulty { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Peaceful => write!(f, "peaceful"), + Self::Easy => write!(f, "easy"), + Self::Normal => write!(f, "normal"), + Self::Hard => write!(f, "hard") + } + } +} + mod say; mod list; mod kill; @@ -52,6 +70,7 @@ mod banlist; mod defaultgamemode; mod op; mod deop; +mod difficulty; impl Command { pub fn raw(cmd: &str) -> Self { @@ -93,4 +112,8 @@ impl Command { pub fn deop() -> deop::DeopCommand { deop::DeopCommand::default() } + + pub fn difficulty() -> difficulty::DifficultyCommand { + difficulty::DifficultyCommand::default() + } } \ No newline at end of file