diff --git a/src/command/kill.rs b/src/command/kill.rs deleted file mode 100644 index bc8b1a2..0000000 --- a/src/command/kill.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[derive(Default)] -pub struct KillCommand { - target: Option -} - -impl KillCommand { - pub fn target(mut self, target: super::Selector) -> Self { - self.target = Some(target); - self - } - - pub fn build(self) -> super::Command { - let target = self.target.unwrap_or(super::Selector::Executor); - let s = format!("kill {target}"); - super::Command(s) - } -} \ No newline at end of file diff --git a/src/command/list.rs b/src/command/list.rs index fed9ccd..23dad11 100644 --- a/src/command/list.rs +++ b/src/command/list.rs @@ -1,16 +1,16 @@ #[derive(Default)] pub struct ListCommand { - uuids: Option + uuids: bool } impl ListCommand { pub fn uuids(mut self) -> Self { - self.uuids = Some(true); + self.uuids = true; self } pub fn build(self) -> super::Command { - let uuids = self.uuids.unwrap_or(false); + let uuids = self.uuids; let mut s = format!("list"); if uuids { s.push_str(" uuids"); diff --git a/src/command/mod.rs b/src/command/mod.rs index 20a4275..e9c5ad9 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,32 +1,7 @@ -use std::fmt::Display; - pub struct Command(String); -pub enum Selector { - NearestPlayer, // @p - RandomPlayer, // @r - AllPlayers, // @a - AllEntities, // @e - Executor, // @s - NearestEntity // @n -} - -impl Display for Selector { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::NearestPlayer => write!(f, "@p"), - Self::RandomPlayer => write!(f, "@r"), - Self::AllPlayers => write!(f, "@a"), - Self::AllEntities => write!(f, "@e"), - Self::Executor => write!(f, "@s"), - Self::NearestEntity => write!(f, "@n") - } - } -} - mod say; mod list; -mod kill; impl Command { pub fn raw(cmd: &str) -> Self { diff --git a/src/command/say.rs b/src/command/say.rs index 6f92b75..471e694 100644 --- a/src/command/say.rs +++ b/src/command/say.rs @@ -1,16 +1,16 @@ #[derive(Default)] pub struct SayCommand { - message: Option + message: String } impl SayCommand { pub fn message(mut self, msg: impl Into) -> Self { - self.message = Some(msg.into()); + self.message = msg.into(); self } pub fn build(self) -> super::Command { - let message = self.message.unwrap_or("Hello, world!".to_string()); + let message = self.message; let s = format!("say {message}"); super::Command(s) } diff --git a/src/lib.rs b/src/lib.rs index 2a184a5..b80ff33 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,4 +2,4 @@ mod client; pub use client::{RconClient, RconError, RconResult}; mod command; -pub use command::{Command, Selector}; \ No newline at end of file +pub use command::Command; \ No newline at end of file