1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Command trait for server commands.
//!
//! Each command implements this trait and is registered on a
//! [`CommandRegistry`](super::CommandRegistry). When a player
//! types `/name args`, the registry looks up the command by name
//! and calls `execute` with the arguments and context.
use crateContext;
use CommandArgs;
/// A server command that can be executed by players or the console.
///
/// # Example
///
/// ```ignore
/// use basalt_api::command::Command;
/// use crate::context::Context;
///
/// pub struct PingCommand;
///
/// impl Command for PingCommand {
/// fn name(&self) -> &str { "ping" }
/// fn description(&self) -> &str { "Responds with pong" }
/// fn execute(&self, _args: &CommandArgs, ctx: &dyn Context) {
/// ctx.chat().send("Pong!");
/// }
/// }
/// ```