47 lines
No EOL
996 B
Rust
47 lines
No EOL
996 B
Rust
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 {
|
|
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()
|
|
}
|
|
} |