From 3122f68720ef4598590b92a677b22d685f5a06f7 Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:24:10 +0200 Subject: [PATCH 1/5] add selector --- src/command/mod.rs | 9 +++++++++ src/lib.rs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/command/mod.rs b/src/command/mod.rs index e9c5ad9..fbed955 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,5 +1,14 @@ pub struct Command(String); +pub enum Selector { + NearestPlayer, // @p + RandomPlayer, // @r + AllPlayers, // @a + AllEntities, // @e + Executor, // @s + NearestEntity // @n +} + mod say; mod list; diff --git a/src/lib.rs b/src/lib.rs index b80ff33..2a184a5 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; \ No newline at end of file +pub use command::{Command, Selector}; \ No newline at end of file From 398615573c22f7d73df5c623b8cd89448f3c3c62 Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:25:04 +0200 Subject: [PATCH 2/5] make list use Option --- src/command/list.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command/list.rs b/src/command/list.rs index 23dad11..fed9ccd 100644 --- a/src/command/list.rs +++ b/src/command/list.rs @@ -1,16 +1,16 @@ #[derive(Default)] pub struct ListCommand { - uuids: bool + uuids: Option } impl ListCommand { pub fn uuids(mut self) -> Self { - self.uuids = true; + self.uuids = Some(true); self } pub fn build(self) -> super::Command { - let uuids = self.uuids; + let uuids = self.uuids.unwrap_or(false); let mut s = format!("list"); if uuids { s.push_str(" uuids"); From dbf872baeba6097928080f50d6bb4ad696ac221a Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:31:37 +0200 Subject: [PATCH 3/5] implement Display for Selector --- src/command/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/command/mod.rs b/src/command/mod.rs index fbed955..20a4275 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + pub struct Command(String); pub enum Selector { @@ -9,8 +11,22 @@ pub enum Selector { 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 { From f01661339e5592fb24cee231a1e004dad5912e5f Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:31:47 +0200 Subject: [PATCH 4/5] add kill --- src/command/kill.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/command/kill.rs diff --git a/src/command/kill.rs b/src/command/kill.rs new file mode 100644 index 0000000..bc8b1a2 --- /dev/null +++ b/src/command/kill.rs @@ -0,0 +1,17 @@ +#[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 From 32304f4ea0d403871580883c11b45cf028abf459 Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:34:33 +0200 Subject: [PATCH 5/5] make say use Option --- src/command/say.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command/say.rs b/src/command/say.rs index 471e694..6f92b75 100644 --- a/src/command/say.rs +++ b/src/command/say.rs @@ -1,16 +1,16 @@ #[derive(Default)] pub struct SayCommand { - message: String + message: Option } impl SayCommand { pub fn message(mut self, msg: impl Into) -> Self { - self.message = msg.into(); + self.message = Some(msg.into()); self } pub fn build(self) -> super::Command { - let message = self.message; + let message = self.message.unwrap_or("Hello, world!".to_string()); let s = format!("say {message}"); super::Command(s) }