add difficulty

This commit is contained in:
Raptorox 2026-08-01 14:55:25 +02:00
parent ae432d79e9
commit 75779c6fe9
No known key found for this signature in database
GPG key ID: 8B3556FC3ED1F6D8
2 changed files with 42 additions and 0 deletions

19
src/command/difficulty.rs Normal file
View file

@ -0,0 +1,19 @@
#[derive(Default)]
pub struct DifficultyCommand {
difficulty: Option<super::Difficulty>
}
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)
}
}

View file

@ -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()
}
}