mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Merge 30cc0ed8bf
into ebc2e0c067
This commit is contained in:
commit
f489eadc56
1 changed files with 39 additions and 0 deletions
39
azalea/examples/resource_pack.rs
Normal file
39
azalea/examples/resource_pack.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
//! A simple bot that repeats chat messages sent by other players.
|
||||
|
||||
use azalea::prelude::*;
|
||||
use azalea_protocol::packets::game::ClientboundGamePacket;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let account = Account::offline("bot");
|
||||
// or let account = Account::microsoft("email").await.unwrap();
|
||||
|
||||
ClientBuilder::new()
|
||||
.set_handler(handle)
|
||||
.reconnect_after(None)
|
||||
.start(account, "localhost")
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Component)]
|
||||
pub struct State {}
|
||||
|
||||
async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> {
|
||||
match event {
|
||||
Event::Packet(packet) => {
|
||||
if let ClientboundGamePacket::ResourcePackPush(push_pack) = packet.as_ref() {
|
||||
println!("Resource Pack URL: {}", push_pack.url);
|
||||
|
||||
bot.disconnect();
|
||||
}
|
||||
}
|
||||
Event::Disconnect(_) => {
|
||||
std::process::exit(0);
|
||||
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Reference in a new issue