1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

Merge branch 'main' into inventory

This commit is contained in:
mat 2023-03-08 16:24:53 +00:00
commit ba713916ee
6 changed files with 28 additions and 5 deletions

View file

@ -1,4 +1,6 @@
on: push
on:
push:
pull_request:
name: Clippy check
jobs:
clippy_check:

View file

@ -149,6 +149,7 @@ impl Client {
entity: self.entity,
content: content.to_string(),
});
self.run_schedule_sender.send(()).unwrap();
}
}
@ -228,9 +229,15 @@ fn handle_send_chat_kind_event(
mut send_packet_events: EventWriter<SendPacketEvent>,
) {
for event in events.iter() {
let content = event
.content
.chars()
.filter(|c| !matches!(c, '\x00'..='\x1F' | '\x7F' | '§'))
.take(256)
.collect::<String>();
let packet = match event.kind {
ChatPacketKind::Message => ServerboundChatPacket {
message: event.content.clone(),
message: content,
timestamp: SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Time shouldn't be before epoch")
@ -245,7 +252,7 @@ fn handle_send_chat_kind_event(
ChatPacketKind::Command => {
// TODO: chat signing
ServerboundChatCommandPacket {
command: event.content.clone(),
command: content,
timestamp: SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Time shouldn't be before epoch")

View file

@ -23,7 +23,7 @@ pub fn minecraft_dir() -> Option<PathBuf> {
pub fn home_env_var() -> &'static str {
#[cfg(target_os = "windows")]
{
"USERPROFILE"
"APPDATA"
}
#[cfg(target_os = "macos")]
{

View file

@ -176,7 +176,9 @@ async fn swarm_handle(
SwarmEvent::Disconnect(account) => {
println!("bot got kicked! {}", account.username);
tokio::time::sleep(Duration::from_secs(5)).await;
swarm.add(account, State::default()).await?;
swarm
.add_with_exponential_backoff(account, State::default())
.await;
}
SwarmEvent::Chat(m) => {
println!("swarm chat message: {}", m.message().to_ansi());

View file

@ -106,6 +106,12 @@ where
self.handler = Some(handler);
self
}
/// Set the client state instead of initializing defaults.
#[must_use]
pub fn set_state(mut self, state: S) -> Self {
self.state = state;
self
}
/// Add a plugin to the client.
#[must_use]
pub fn add_plugin<T: Plugin>(mut self, plugin: T) -> Self {

View file

@ -199,6 +199,12 @@ where
self.swarm_handler = Some(handler);
self
}
/// Set the swarm state instead of initializing defaults.
#[must_use]
pub fn set_swarm_state(mut self, swarm_state: SS) -> Self {
self.swarm_state = swarm_state;
self
}
/// Add a plugin to the swarm.
#[must_use]