diff options
| author | mat <github@matdoes.dev> | 2023-03-01 21:02:42 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2023-03-01 21:02:42 +0000 |
| commit | 7bfca9d228eb58839506f72555650d29ef26ee90 (patch) | |
| tree | ac4e90dd38a2e6e60490a8c541e2129510788d26 | |
| parent | 9b1b03d4ac59676393658f8558194490fe62a060 (diff) | |
| parent | 91d97adb4f03acf2d53dedb598f5496e2c4d9063 (diff) | |
| download | azalea-drasl-7bfca9d228eb58839506f72555650d29ef26ee90.tar.xz | |
Merge branch 'main' of https://github.com/mat-1/azalea into main
| -rwxr-xr-x | .github/workflows/check.yml | 4 | ||||
| -rwxr-xr-x | azalea-client/src/chat.rs | 11 | ||||
| -rwxr-xr-x | azalea-client/src/get_mc_dir.rs | 2 | ||||
| -rw-r--r-- | azalea/src/lib.rs | 6 | ||||
| -rw-r--r-- | azalea/src/swarm/mod.rs | 6 |
5 files changed, 25 insertions, 4 deletions
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f6c4c5d9..6188f070 100755 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,6 @@ -on: push +on: + push: + pull_request: name: Clippy check jobs: clippy_check: diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index 202cf47c..e127f0d7 100755 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -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") diff --git a/azalea-client/src/get_mc_dir.rs b/azalea-client/src/get_mc_dir.rs index 440550a7..df2a81aa 100755 --- a/azalea-client/src/get_mc_dir.rs +++ b/azalea-client/src/get_mc_dir.rs @@ -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")] { diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 4e21fbbd..827c3904 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -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 { diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 9edaa305..c0d9cb56 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -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] |
