From 75779c6fe915983f524fd63449dc8258d8f266d2 Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Sat, 1 Aug 2026 14:55:25 +0200 Subject: [PATCH] add difficulty --- src/command/difficulty.rs | 19 +++++++++++++++++++ src/command/mod.rs | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/command/difficulty.rs 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