pub mod combat; pub mod debug; pub mod movement; use azalea::{ Client, brigadier::prelude::*, chat::ChatPacket, ecs::prelude::*, entity::metadata::Player, player::GameProfileComponent, }; use parking_lot::Mutex; use crate::State; pub type Ctx = CommandContext>; pub struct CommandSource { pub bot: Client, pub state: State, pub chat: ChatPacket, } impl CommandSource { pub fn reply(&self, message: impl Into) { let message = message.into(); if self.chat.is_whisper() { self.bot .chat(&format!("/w {} {message}", self.chat.sender().unwrap())); } else { self.bot.chat(&message); } } pub fn entity(&mut self) -> Option { let username = self.chat.sender()?; self.bot.entity_by::, &GameProfileComponent>( |profile: &&GameProfileComponent| profile.name == username, ) } } pub fn register_commands(commands: &mut CommandDispatcher>) { combat::register(commands); debug::register(commands); movement::register(commands); }