Add a stop command
Note that this command does not stop gracefully for now
This commit is contained in:
parent
ade661d5b8
commit
96b86f1e9b
@ -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());
|
||||
}
|
||||
|
||||
17
pumpkin/src/commands/stop.rs
Normal file
17
pumpkin/src/commands/stop.rs
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user