Add a stop command
Note that this command does not stop gracefully for now
This commit is contained in:
1 parent
ade661d5b8
commit
96b86f1e9b
2 files changed
+23
No files matched your search
@@ -1,11 +1,13 @@
|
|||||||
use gamemode::GamemodeCommand;
|
use gamemode::GamemodeCommand;
|
||||||
use pumpkin::PumpkinCommand;
|
use pumpkin::PumpkinCommand;
|
||||||
use pumpkin_text::TextComponent;
|
use pumpkin_text::TextComponent;
|
||||||
|
use stop::StopCommand;
|
||||||
|
|
||||||
use crate::client::Client;
|
use crate::client::Client;
|
||||||
|
|
||||||
mod gamemode;
|
mod gamemode;
|
||||||
mod pumpkin;
|
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
|
/// 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> {
|
pub trait Command<'a> {
|
||||||
@@ -72,6 +74,10 @@ pub fn handle_command(sender: &mut CommandSender, command: &str) {
|
|||||||
GamemodeCommand::on_execute(sender, command);
|
GamemodeCommand::on_execute(sender, command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if command.starts_with(StopCommand::NAME) {
|
||||||
|
StopCommand::on_execute(sender, command);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO: red color
|
// TODO: red color
|
||||||
sender.send_message("Command not Found".into());
|
sender.send_message("Command not Found".into());
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user