aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/testbot/commands/combat.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-01-07 21:50:38 -0600
committermat <git@matdoes.dev>2024-01-07 21:50:38 -0600
commit0aa439d5caa8028b6d310de45258cbcef16ca2eb (patch)
tree7c8c201935eb62196c2d57718965861724d22fe8 /azalea/examples/testbot/commands/combat.rs
parent5ea127114582e3320381d09e880f6a433ccb8710 (diff)
downloadazalea-drasl-0aa439d5caa8028b6d310de45258cbcef16ca2eb.tar.xz
rewrite testbot to use brigadier
Diffstat (limited to 'azalea/examples/testbot/commands/combat.rs')
-rw-r--r--azalea/examples/testbot/commands/combat.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/azalea/examples/testbot/commands/combat.rs b/azalea/examples/testbot/commands/combat.rs
new file mode 100644
index 00000000..b440b3ac
--- /dev/null
+++ b/azalea/examples/testbot/commands/combat.rs
@@ -0,0 +1,26 @@
+use azalea::brigadier::prelude::*;
+use parking_lot::Mutex;
+
+use super::{CommandSource, Ctx};
+
+pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
+ commands.register(
+ literal("killaura").then(argument("enabled", bool()).executes(|ctx: &Ctx| {
+ let enabled = get_bool(ctx, "enabled").unwrap();
+ let source = ctx.source.lock();
+ let bot = source.bot.clone();
+ {
+ let mut ecs = bot.ecs.lock();
+ let mut entity = ecs.entity_mut(bot.entity);
+ let mut state = entity.get_mut::<crate::State>().unwrap();
+ state.killaura = enabled
+ }
+ source.reply(if enabled {
+ "Enabled killaura"
+ } else {
+ "Disabled killaura"
+ });
+ 1
+ })),
+ );
+}