add defaultgamemode
This commit is contained in:
parent
f835beef10
commit
4f202c8ade
2 changed files with 40 additions and 0 deletions
17
src/command/defaultgamemode.rs
Normal file
17
src/command/defaultgamemode.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#[derive(Default)]
|
||||
pub struct DefaultGamemodeCommand {
|
||||
gamemode: Option<super::Gamemode>
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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::NoFilter> {
|
||||
banlist::BanlistCommand::new()
|
||||
}
|
||||
|
||||
pub fn defaultgamemode() -> defaultgamemode::DefaultGamemodeCommand {
|
||||
defaultgamemode::DefaultGamemodeCommand::default()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue