add difficulty
This commit is contained in:
parent
ae432d79e9
commit
75779c6fe9
2 changed files with 42 additions and 0 deletions
19
src/command/difficulty.rs
Normal file
19
src/command/difficulty.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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 say;
|
||||||
mod list;
|
mod list;
|
||||||
mod kill;
|
mod kill;
|
||||||
|
|
@ -52,6 +70,7 @@ mod banlist;
|
||||||
mod defaultgamemode;
|
mod defaultgamemode;
|
||||||
mod op;
|
mod op;
|
||||||
mod deop;
|
mod deop;
|
||||||
|
mod difficulty;
|
||||||
|
|
||||||
impl Command {
|
impl Command {
|
||||||
pub fn raw(cmd: &str) -> Self {
|
pub fn raw(cmd: &str) -> Self {
|
||||||
|
|
@ -93,4 +112,8 @@ impl Command {
|
||||||
pub fn deop() -> deop::DeopCommand {
|
pub fn deop() -> deop::DeopCommand {
|
||||||
deop::DeopCommand::default()
|
deop::DeopCommand::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn difficulty() -> difficulty::DifficultyCommand {
|
||||||
|
difficulty::DifficultyCommand::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue