You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

use valence::prelude::*;
use crate::{GameState, CONFIG};
use super::Command;
pub fn run(
command: Command,
client: &mut Client,
uuid: Uuid,
next_state: &mut ResMut<NextState<GameState>>,
state: &Res<State<GameState>>,
) {
if CONFIG.operators.contains(&uuid) {
if let Some(args) = command.args {
match args[0].as_str() {
"start" => next_state.set(GameState::Started),
"stop" => next_state.set(GameState::Stopped),
_ => client.send_message("Invalid game state!"),
}
} else {
client.send_message(format!(
"The game is currently {}",
match state.0 {
GameState::Started => "started",
GameState::Stopped => "stopped",
}
));
}
} else {
client.send_message(
"You do not have the permission to execute this command."
.bold()
.color(Color::RED),
);
}
}