steel_core/command/builtins/
stop.rs1use steel_utils::{Identifier, translations::COMMANDS_STOP_STOPPING};
2use text_components::TextComponent;
3
4use super::super::{
5 brigadier::{CommandNodeBuilder, CommandSyntaxError},
6 execution::{CommandSource, SteelCommandContext, SteelCommandRuntime, literal},
7 registration::CommandRegistration,
8};
9
10pub(super) fn registration() -> CommandRegistration<CommandSource> {
11 CommandRegistration::new(Identifier::vanilla_static("stop"), |_| command())
12}
13
14fn command() -> CommandNodeBuilder<CommandSource, SteelCommandRuntime> {
15 literal("stop").executes(stop_server)
16}
17
18#[expect(
19 clippy::unnecessary_wraps,
20 reason = "Command executors use a shared fallible callback signature."
21)]
22fn stop_server(context: &SteelCommandContext<CommandSource>) -> Result<i32, CommandSyntaxError> {
23 context
24 .source()
25 .send_success(&TextComponent::from(&COMMANDS_STOP_STOPPING), true);
26 context.source().server().cancel_token.cancel();
27 Ok(1)
28}