diff --git a/pumpkin/src/commands/mod.rs b/pumpkin/src/commands/mod.rs index 3e75202a..dc687430 100644 --- a/pumpkin/src/commands/mod.rs +++ b/pumpkin/src/commands/mod.rs @@ -1,11 +1,13 @@ use gamemode::GamemodeCommand; use pumpkin::PumpkinCommand; use pumpkin_text::TextComponent; +use stop::StopCommand; use crate::client::Client; mod gamemode; mod pumpkin; +mod stop; /// I think it would be great to split this up into a seperate crate, But idk how i should do that, Because we have to rely on Client and Server pub trait Command<'a> { @@ -72,6 +74,10 @@ pub fn handle_command(sender: &mut CommandSender, command: &str) { GamemodeCommand::on_execute(sender, command); return; } + if command.starts_with(StopCommand::NAME) { + StopCommand::on_execute(sender, command); + return; + } // TODO: red color sender.send_message("Command not Found".into()); } diff --git a/pumpkin/src/commands/stop.rs b/pumpkin/src/commands/stop.rs new file mode 100644 index 00000000..09d62122 --- /dev/null +++ b/pumpkin/src/commands/stop.rs @@ -0,0 +1,17 @@ +use super::Command; + +pub struct StopCommand { + +} + +impl<'a> Command<'a> for StopCommand { + const NAME: &'static str = "stop"; + const DESCRIPTION: &'static str = "Stops the server"; + + fn on_execute(sender: &mut super::CommandSender<'a>, command: String) { + std::process::exit(0); + } + fn player_required() -> bool { + true + } +} \ No newline at end of file