From 4f202c8ade3e4b512eac7d9804df73a727574bdf Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Sat, 1 Aug 2026 14:29:39 +0200 Subject: [PATCH] add defaultgamemode --- src/command/defaultgamemode.rs | 17 +++++++++++++++++ src/command/mod.rs | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/command/defaultgamemode.rs diff --git a/src/command/defaultgamemode.rs b/src/command/defaultgamemode.rs new file mode 100644 index 0000000..324df9d --- /dev/null +++ b/src/command/defaultgamemode.rs @@ -0,0 +1,17 @@ +#[derive(Default)] +pub struct DefaultGamemodeCommand { + gamemode: Option +} + +impl DefaultGamemodeCommand { + pub fn gamemode(mut self, gamemode: super::Gamemode) -> Self { + self.gamemode = Some(gamemode); + self + } + + pub fn build(self) -> super::Command { + let gamemode = self.gamemode.unwrap_or(super::Gamemode::Survival); + let s = format!("defaultgamemode {gamemode}"); + super::Command(s) + } +} \ No newline at end of file diff --git a/src/command/mod.rs b/src/command/mod.rs index 407e929..674b0c5 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -26,11 +26,30 @@ impl Display for Selector { } } +pub enum Gamemode { + Survival, + Creative, + Adventure, + Spectator +} + +impl Display for Gamemode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Survival => write!(f, "survival"), + Self::Creative => write!(f, "creative"), + Self::Adventure => write!(f, "adventure"), + Self::Spectator => write!(f, "spectator") + } + } +} + mod say; mod list; mod kill; mod ban; mod banlist; +mod defaultgamemode; impl Command { pub fn raw(cmd: &str) -> Self { @@ -60,4 +79,8 @@ impl Command { pub fn banlist() -> banlist::BanlistCommand { banlist::BanlistCommand::new() } + + pub fn defaultgamemode() -> defaultgamemode::DefaultGamemodeCommand { + defaultgamemode::DefaultGamemodeCommand::default() + } } \ No newline at end of file