Added ban command functionality

This commit is contained in:
tylerlowrey 2020-07-16 16:56:11 -04:00 committed by Joshua Yanovski
parent dadb1fbe12
commit def21af02b
2 changed files with 23 additions and 7 deletions

View File

@ -1860,13 +1860,29 @@ fn handle_ban(
server: &mut Server,
client: EcsEntity,
_target: EcsEntity,
_args: String,
_action: &ChatCommand,
args: String,
action: &ChatCommand,
) {
server.notify_client(
client,
ChatType::CommandInfo.server_msg("This command is not yet implemented")
)
if let (Some(target_alias), reason_opt) = scan_fmt_some!(&args, &action.arg_fmt(), String, String) {
let reason = reason_opt.unwrap_or(String::new());
server.settings_mut().edit(|s| {
s.banlist.push((target_alias.clone(), reason.clone()))
});
server.notify_client(
client,
ChatType::CommandInfo.server_msg(
format!("Added {} to the banlist with reason: {}",
target_alias,
reason))
);
} else {
server.notify_client(
client,
ChatType::CommandError.server_msg(action.help_string())
);
}
}
fn handle_unban(

View File

@ -20,7 +20,7 @@ pub struct ServerSettings {
pub start_time: f64,
pub admins: Vec<String>,
pub whitelist: Vec<String>,
pub banlist: Vec<String>,
pub banlist: Vec<(String, String)>,
/// When set to None, loads the default map file (if available); otherwise,
/// uses the value of the file options to decide how to proceed.
pub map_file: Option<FileOpts>,