This repository was archived by the owner on Feb 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask_manager_queue.rs
More file actions
76 lines (69 loc) · 2.46 KB
/
Copy pathtask_manager_queue.rs
File metadata and controls
76 lines (69 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use azalea::BlockPos;
use azalea_anti_afk::config::AntiAFKConfig;
use std::collections::VecDeque;
use std::time::Duration;
#[derive(Default, Clone)]
pub struct TaskManagerQueue {
tasks: VecDeque<Task>,
}
#[derive(Clone)]
pub enum Task {
/// Uses azalea's pathfinding to go the `BlockPos`.
///
/// It tasks two parameters,
///
/// `target:` [`BlockPos`](azalea::BlockPos) -> Target Position
///
/// `allow_mining: bool` -> Is the bot allowed to mine
///
/// `distance: f64` -> The distance at which pathfinding should stop. It should have
/// minimum value of `2.0` (including error).
///
/// Note: Next Task will be executed once, the bot has reached there
GotoTask(BlockPos, bool, f64),
/// This is the implementation of [`Client::block_interact()`](azalea::Client::block_interact)
///
/// Note: The bot needs to be in the range to interact with the block
InteractWithBlock(BlockPos),
/// Sends chat message
///
/// Implementation of [`bot.send_chat_packet()`](azalea::Client::send_chat_packet)
SendChatMessage(String),
/// As the name suggest, it adds delay between tasks
Delay(Duration),
#[cfg(feature = "anti-afk")]
/// This task, can set [`AntiAFK`](azalea_anti_afk::AntiAFK) state to `false` or `true`.
///
/// NOTE: You need to add the plugin [`AntiAFKPlugin`](azalea_anti_afk::AntiAFKPlugin) before
/// sending this task.
///
/// This task is equivalent to [`bot.set_anti_afk()`](azalea_anti_afk::AntiAFKClientExt::set_anti_afk).
/// Also, this is not as effective to it because it can overwrite component if enabled twice.
/// This is not a deal-breaker for `AntiAFKPlugin`.
SetAntiAFK(bool, Option<AntiAFKConfig>),
}
impl TaskManagerQueue {
/// Adds a single task to the TaskManagerQueue.
pub fn add(&mut self, task: Task) {
self.tasks.push_back(task)
}
/// Adds multiple task to the TaskManagerQueue
pub fn add_multiple(&mut self, tasks: Vec<Task>) {
for task in tasks {
self.add(task)
}
}
/// Removes the first task
pub fn remove(&mut self) {
self.tasks.pop_front();
}
#[allow(clippy::len_without_is_empty)]
/// Returns the length of tasks
pub fn len(&self) -> usize {
self.tasks.len()
}
/// Implementation of [`VecDeque::get`](std::collections::VecDeque::get)
pub fn get(&self, index: usize) -> Option<&Task> {
self.tasks.get(index)
}
}