From 4ac4e2b5a7630a84e028ea4d916b83adecbac053 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Mon, 23 Jan 2023 22:53:35 +0800 Subject: [PATCH] Add alert pause durations --- README.md | 1 + src/main.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb72c6a..dd84449 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ alert_command = [ "-d{player_name} is near your base! Their coordinates are {x} {y} {z}.", "" ] +alert_pause_time = 5 # the amount of seconds to wait between alert messages cleanup_interval = 300 # the amount of seconds to wait before checking for idle entities mob_expiry_time = 300 # the maximum amount of time a mob can stay idle before getting cleared mob_packet_drop_level = 5 # the amount of mob packets to drop (0 = 0%, 5 = 50%, 10 = 100%) diff --git a/src/main.rs b/src/main.rs index fce5217..e6e9e83 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,7 @@ struct BotConfiguration { alert_location: Vec, alert_radius: u32, alert_command: Vec, + alert_pause_time: u32, cleanup_interval: u32, mob_expiry_time: u64, mob_packet_drop_level: u8, @@ -50,6 +51,7 @@ impl Default for BotConfiguration { alert_location: vec![0, 0], alert_radius: 100, alert_command: Vec::new(), + alert_pause_time: 5, cleanup_interval: 300, mob_expiry_time: 300, mob_packet_drop_level: 5, @@ -279,7 +281,9 @@ async fn handle(mut client: Client, event: Event, mut state: State) -> anyhow::R } } - if *state.alert_second_counter.lock().unwrap() >= 5 { + if *state.alert_second_counter.lock().unwrap() as u32 + >= state.bot_configuration.alert_pause_time + { *state.alert_second_counter.lock().unwrap() = 0; let alert_queue = state.alert_queue.lock().unwrap().to_owned();