26 lines
No EOL
705 B
Rust
26 lines
No EOL
705 B
Rust
#[derive(Default)]
|
|
pub struct GamemodeCommand {
|
|
gamemode: Option<super::Gamemode>,
|
|
target: Option<super::Selector>
|
|
}
|
|
|
|
impl GamemodeCommand {
|
|
pub fn gamemode(mut self, gamemode: super::Gamemode) -> Self {
|
|
self.gamemode = Some(gamemode);
|
|
self
|
|
}
|
|
|
|
pub fn target(mut self, target: super::Selector) -> Self {
|
|
self.target = Some(target);
|
|
self
|
|
}
|
|
|
|
pub fn build(self) -> super::Command {
|
|
let gamemode = self.gamemode.unwrap_or(super::Gamemode::Survival);
|
|
let mut s = format!("defaultgamemode {gamemode}");
|
|
if let Some(target) = self.target {
|
|
s.push_str(&format!(" {target}"))
|
|
}
|
|
super::Command(s)
|
|
}
|
|
} |