use std::fmt::Display; pub struct Command(String); pub enum Selector { NearestPlayer, // @p RandomPlayer, // @r AllPlayers, // @a AllEntities, // @e Executor, // @s NearestEntity, // @n, Player(String) } 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"), Self::Player(name) => write!(f, "{name}") } } } mod say; mod list; mod kill; mod ban; mod banlist; impl Command { pub fn raw(cmd: &str) -> Self { Self(cmd.to_string()) } pub fn as_str(&self) -> &str { &self.0 } pub fn say() -> say::SayCommand { say::SayCommand::default() } pub fn list() -> list::ListCommand { list::ListCommand::default() } pub fn kill() -> kill::KillCommand { kill::KillCommand::default() } pub fn ban() -> ban::BanCommand { ban::BanCommand::default() } pub fn banlist() -> banlist::BanlistCommand { banlist::BanlistCommand::new() } }