add gamemode
This commit is contained in:
parent
75779c6fe9
commit
1485cf975d
2 changed files with 31 additions and 0 deletions
26
src/command/gamemode.rs
Normal file
26
src/command/gamemode.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#[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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -71,6 +71,7 @@ mod defaultgamemode;
|
||||||
mod op;
|
mod op;
|
||||||
mod deop;
|
mod deop;
|
||||||
mod difficulty;
|
mod difficulty;
|
||||||
|
mod gamemode;
|
||||||
|
|
||||||
impl Command {
|
impl Command {
|
||||||
pub fn raw(cmd: &str) -> Self {
|
pub fn raw(cmd: &str) -> Self {
|
||||||
|
|
@ -116,4 +117,8 @@ impl Command {
|
||||||
pub fn difficulty() -> difficulty::DifficultyCommand {
|
pub fn difficulty() -> difficulty::DifficultyCommand {
|
||||||
difficulty::DifficultyCommand::default()
|
difficulty::DifficultyCommand::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn gamemode() -> gamemode::GamemodeCommand {
|
||||||
|
gamemode::GamemodeCommand::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue