aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azalea-auth/src/auth.rs36
-rw-r--r--azalea-auth/src/cache.rs13
-rw-r--r--azalea-block/src/block_state.rs2
-rw-r--r--azalea-brigadier/src/builder/argument_builder.rs7
-rw-r--r--azalea-brigadier/src/context/command_context.rs10
-rw-r--r--azalea-brigadier/src/context/command_context_builder.rs9
-rw-r--r--azalea-brigadier/src/context/context_chain.rs4
-rw-r--r--azalea-brigadier/src/parse_results.rs8
-rw-r--r--azalea-brigadier/src/suggestion/mod.rs10
-rw-r--r--azalea-brigadier/src/suggestion/suggestions.rs4
-rw-r--r--azalea-brigadier/src/tree/mod.rs8
-rw-r--r--azalea-brigadier/tests/bevy_app_usage.rs4
-rw-r--r--azalea-brigadier/tests/suggestion/suggestions_test.rs2
-rw-r--r--azalea-buf/src/read.rs4
-rw-r--r--azalea-buf/src/serializable_uuid.rs4
-rw-r--r--azalea-buf/src/write.rs80
-rw-r--r--azalea-chat/src/component.rs38
-rw-r--r--azalea-chat/src/numbers.rs4
-rw-r--r--azalea-chat/src/style.rs18
-rw-r--r--azalea-chat/src/text_component.rs14
-rw-r--r--azalea-chat/src/translatable_component.rs6
-rw-r--r--azalea-client/src/entity_query.rs6
-rw-r--r--azalea-client/src/local_player.rs12
-rw-r--r--azalea-client/src/plugins/chat_signing.rs34
-rw-r--r--azalea-client/src/plugins/chunks.rs14
-rw-r--r--azalea-client/src/plugins/inventory.rs59
-rw-r--r--azalea-client/src/plugins/join.rs26
-rw-r--r--azalea-client/src/plugins/movement.rs3
-rw-r--r--azalea-client/tests/reply_to_ping_with_pong.rs20
-rw-r--r--azalea-core/src/bitset.rs4
-rw-r--r--azalea-core/src/difficulty.rs8
-rw-r--r--azalea-core/src/filterable.rs4
-rw-r--r--azalea-core/src/game_type.rs6
-rw-r--r--azalea-core/src/objectives.rs4
-rw-r--r--azalea-core/src/position.rs16
-rw-r--r--azalea-core/src/resource_location.rs4
-rw-r--r--azalea-entity/src/data.rs6
-rw-r--r--azalea-entity/src/lib.rs4
-rw-r--r--azalea-entity/src/plugin/indexing.rs4
-rw-r--r--azalea-inventory/src/components.rs12
-rw-r--r--azalea-inventory/src/slot.rs14
-rw-r--r--azalea-physics/src/clip.rs9
-rw-r--r--azalea-physics/src/collision/discrete_voxel_shape.rs26
-rw-r--r--azalea-protocol/azalea-protocol-macros/src/lib.rs6
-rw-r--r--azalea-protocol/src/common/client_information.rs6
-rw-r--r--azalea-protocol/src/common/movements.rs2
-rw-r--r--azalea-protocol/src/lib.rs8
-rw-r--r--azalea-protocol/src/packets/config/c_update_tags.rs6
-rw-r--r--azalea-protocol/src/packets/game/c_boss_event.rs5
-rw-r--r--azalea-protocol/src/packets/game/c_commands.rs8
-rw-r--r--azalea-protocol/src/packets/game/c_damage_event.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_map_item_data.rs6
-rw-r--r--azalea-protocol/src/packets/game/c_player_abilities.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_player_chat.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_player_info_update.rs6
-rw-r--r--azalea-protocol/src/packets/game/c_section_blocks_update.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_set_equipment.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_set_objective.rs6
-rw-r--r--azalea-protocol/src/packets/game/c_stop_sound.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_update_advancements.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_update_tags.rs6
-rw-r--r--azalea-protocol/src/packets/game/s_interact.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_player_abilities.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_player_input.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_seen_advancements.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_set_command_block.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_set_jigsaw_block.rs3
-rw-r--r--azalea-protocol/src/packets/game/s_set_structure_block.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_use_item_on.rs4
-rw-r--r--azalea-protocol/src/packets/login/c_login_disconnect.rs6
-rw-r--r--azalea-protocol/src/packets/mod.rs6
-rw-r--r--azalea-protocol/src/packets/status/c_status_response.rs4
-rw-r--r--azalea-protocol/src/read.rs8
-rw-r--r--azalea-registry/src/lib.rs8
-rw-r--r--azalea-world/src/chunk_storage.rs7
-rw-r--r--azalea-world/src/heightmap.rs7
-rw-r--r--azalea-world/src/palette.rs6
-rw-r--r--azalea-world/src/world.rs14
-rw-r--r--azalea/examples/echo.rs15
-rw-r--r--azalea/examples/testbot/commands/debug.rs4
-rw-r--r--azalea/src/container.rs6
-rw-r--r--azalea/src/pathfinder/astar.rs4
-rw-r--r--azalea/src/pathfinder/mod.rs3
-rw-r--r--azalea/src/pathfinder/moves/mod.rs7
84 files changed, 428 insertions, 381 deletions
diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs
index 99dfc115..51e44a70 100644
--- a/azalea-auth/src/auth.rs
+++ b/azalea-auth/src/auth.rs
@@ -3,13 +3,14 @@
use std::{
collections::HashMap,
path::PathBuf,
- time::{Instant, SystemTime, UNIX_EPOCH},
+ time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::json;
use thiserror::Error;
+use tokio::time::sleep;
use tracing::{error, trace};
use uuid::Uuid;
@@ -75,8 +76,9 @@ pub async fn auth(email: &str, opts: AuthOpts<'_>) -> Result<AuthResult, AuthErr
None
};
- if cached_account.is_some() && !cached_account.as_ref().unwrap().mca.is_expired() {
- let account = cached_account.as_ref().unwrap();
+ if let Some(account) = &cached_account
+ && !account.mca.is_expired()
+ {
// the minecraft auth data is cached and not expired, so we can just
// use that instead of doing auth all over again :)
@@ -129,8 +131,8 @@ pub async fn auth(email: &str, opts: AuthOpts<'_>) -> Result<AuthResult, AuthErr
let profile: ProfileResponse = get_profile(&client, &res.minecraft_access_token).await?;
- if let Some(cache_file) = opts.cache_file {
- if let Err(e) = cache::set_account_in_cache(
+ if let Some(cache_file) = opts.cache_file
+ && let Err(e) = cache::set_account_in_cache(
&cache_file,
email,
CachedAccount {
@@ -142,9 +144,8 @@ pub async fn auth(email: &str, opts: AuthOpts<'_>) -> Result<AuthResult, AuthErr
},
)
.await
- {
- error!("{}", e);
- }
+ {
+ error!("{}", e);
}
Ok(AuthResult {
@@ -328,7 +329,7 @@ pub async fn get_ms_link_code(
Ok(client
.post("https://login.live.com/oauth20_connect.srf")
- .form(&vec![
+ .form(&[
("scope", scope),
("client_id", client_id),
("response_type", "device_code"),
@@ -354,17 +355,17 @@ pub async fn get_ms_auth_token(
CLIENT_ID
};
- let login_expires_at = Instant::now() + std::time::Duration::from_secs(res.expires_in);
+ let login_expires_at = Instant::now() + Duration::from_secs(res.expires_in);
while Instant::now() < login_expires_at {
- tokio::time::sleep(std::time::Duration::from_secs(res.interval)).await;
+ sleep(Duration::from_secs(res.interval)).await;
trace!("Polling to check if user has logged in...");
let res = client
.post(format!(
"https://login.live.com/oauth20_token.srf?client_id={client_id}"
))
- .form(&vec![
+ .form(&[
("client_id", client_id),
("device_code", &res.device_code),
("grant_type", "urn:ietf:params:oauth:grant-type:device_code"),
@@ -375,8 +376,8 @@ pub async fn get_ms_auth_token(
.await;
if let Ok(access_token_response) = res {
trace!("access_token_response: {:?}", access_token_response);
- let expires_at = SystemTime::now()
- + std::time::Duration::from_secs(access_token_response.expires_in);
+ let expires_at =
+ SystemTime::now() + Duration::from_secs(access_token_response.expires_in);
return Ok(ExpiringValue {
data: access_token_response,
expires_at: expires_at
@@ -428,7 +429,7 @@ pub async fn refresh_ms_auth_token(
let access_token_response_text = client
.post("https://login.live.com/oauth20_token.srf")
- .form(&vec![
+ .form(&[
("scope", scope),
("client_id", client_id),
("grant_type", "refresh_token"),
@@ -441,8 +442,7 @@ pub async fn refresh_ms_auth_token(
let access_token_response: AccessTokenResponse =
serde_json::from_str(&access_token_response_text)?;
- let expires_at =
- SystemTime::now() + std::time::Duration::from_secs(access_token_response.expires_in);
+ let expires_at = SystemTime::now() + Duration::from_secs(access_token_response.expires_in);
Ok(ExpiringValue {
data: access_token_response,
expires_at: expires_at
@@ -558,7 +558,7 @@ async fn auth_with_minecraft(
.await?;
trace!("{:?}", res);
- let expires_at = SystemTime::now() + std::time::Duration::from_secs(res.expires_in);
+ let expires_at = SystemTime::now() + Duration::from_secs(res.expires_in);
Ok(ExpiringValue {
data: res,
// to seconds since epoch
diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs
index ca32958f..9207c46e 100644
--- a/azalea-auth/src/cache.rs
+++ b/azalea-auth/src/cache.rs
@@ -1,22 +1,23 @@
//! Cache auth information
+use std::io;
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize};
use thiserror::Error;
-use tokio::fs::File;
+use tokio::fs::{self, File};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tracing::{debug, trace};
#[derive(Debug, Error)]
pub enum CacheError {
#[error("Failed to read cache file: {0}")]
- Read(std::io::Error),
+ Read(io::Error),
#[error("Failed to write cache file: {0}")]
- Write(std::io::Error),
+ Write(io::Error),
#[error("Failed to create cache file directory: {0}")]
- MkDir(std::io::Error),
+ MkDir(io::Error),
#[error("Failed to parse cache file: {0}")]
Parse(serde_json::Error),
}
@@ -94,7 +95,9 @@ async fn set_entire_cache(cache_file: &Path, cache: Vec<CachedAccount>) -> Resul
"Making cache file parent directory at {}",
cache_file_parent.to_string_lossy()
);
- std::fs::create_dir_all(cache_file_parent).map_err(CacheError::MkDir)?;
+ fs::create_dir_all(cache_file_parent)
+ .await
+ .map_err(CacheError::MkDir)?;
}
let mut cache_file = File::create(cache_file).await.map_err(CacheError::Write)?;
let cache = serde_json::to_string_pretty(&cache).map_err(CacheError::Parse)?;
diff --git a/azalea-block/src/block_state.rs b/azalea-block/src/block_state.rs
index 9dd2e741..ab0ca076 100644
--- a/azalea-block/src/block_state.rs
+++ b/azalea-block/src/block_state.rs
@@ -104,7 +104,7 @@ impl AzaleaRead for BlockState {
}
}
impl AzaleaWrite for BlockState {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
u32::azalea_write_var(&(self.id as u32), buf)
}
}
diff --git a/azalea-brigadier/src/builder/argument_builder.rs b/azalea-brigadier/src/builder/argument_builder.rs
index 1731d44d..4b314887 100644
--- a/azalea-brigadier/src/builder/argument_builder.rs
+++ b/azalea-brigadier/src/builder/argument_builder.rs
@@ -1,4 +1,7 @@
-use std::{fmt::Debug, sync::Arc};
+use std::{
+ fmt::{self, Debug},
+ sync::Arc,
+};
use parking_lot::RwLock;
@@ -184,7 +187,7 @@ impl<S> ArgumentBuilder<S> {
}
impl<S> Debug for ArgumentBuilder<S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ArgumentBuilder")
.field("arguments", &self.arguments)
// .field("command", &self.command)
diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs
index d50c94ab..a9959895 100644
--- a/azalea-brigadier/src/context/command_context.rs
+++ b/azalea-brigadier/src/context/command_context.rs
@@ -1,4 +1,10 @@
-use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
+use std::{
+ any::Any,
+ collections::HashMap,
+ fmt::{self, Debug},
+ rc::Rc,
+ sync::Arc,
+};
use parking_lot::RwLock;
@@ -40,7 +46,7 @@ impl<S> Clone for CommandContext<S> {
}
impl<S> Debug for CommandContext<S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CommandContext")
// .field("source", &self.source)
.field("input", &self.input)
diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs
index 87427bc1..f8d4334d 100644
--- a/azalea-brigadier/src/context/command_context_builder.rs
+++ b/azalea-brigadier/src/context/command_context_builder.rs
@@ -1,4 +1,9 @@
-use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
+use std::{
+ collections::HashMap,
+ fmt::{self, Debug},
+ rc::Rc,
+ sync::Arc,
+};
use parking_lot::RwLock;
@@ -140,7 +145,7 @@ impl<'a, S> CommandContextBuilder<'a, S> {
}
impl<S> Debug for CommandContextBuilder<'_, S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CommandContextBuilder")
// .field("arguments", &self.arguments)
.field("root", &self.root)
diff --git a/azalea-brigadier/src/context/context_chain.rs b/azalea-brigadier/src/context/context_chain.rs
index 74fe6e01..afafe957 100644
--- a/azalea-brigadier/src/context/context_chain.rs
+++ b/azalea-brigadier/src/context/context_chain.rs
@@ -28,9 +28,7 @@ impl<S> ContextChain<S> {
let child = current.child.clone();
let Some(child) = child else {
// Last entry must be executable command
- if current.command.is_none() {
- return None;
- }
+ current.command.as_ref()?;
return Some(ContextChain::new(modifiers, current));
};
diff --git a/azalea-brigadier/src/parse_results.rs b/azalea-brigadier/src/parse_results.rs
index 73de8d47..7d3cf98a 100644
--- a/azalea-brigadier/src/parse_results.rs
+++ b/azalea-brigadier/src/parse_results.rs
@@ -1,4 +1,8 @@
-use std::{collections::HashMap, fmt::Debug, rc::Rc};
+use std::{
+ collections::HashMap,
+ fmt::{self, Debug},
+ rc::Rc,
+};
use crate::{
context::CommandContextBuilder, errors::CommandSyntaxError, string_reader::StringReader,
@@ -12,7 +16,7 @@ pub struct ParseResults<'a, S> {
}
impl<S> Debug for ParseResults<'_, S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ParseResults")
.field("context", &self.context)
// .field("reader", &self.reader)
diff --git a/azalea-brigadier/src/suggestion/mod.rs b/azalea-brigadier/src/suggestion/mod.rs
index a1c385cc..af29264e 100644
--- a/azalea-brigadier/src/suggestion/mod.rs
+++ b/azalea-brigadier/src/suggestion/mod.rs
@@ -5,8 +5,10 @@ mod suggestions_builder;
#[cfg(feature = "azalea-buf")]
use std::io::Write;
use std::{
+ cmp::Ordering,
fmt::{self, Display},
hash::Hash,
+ io,
};
#[cfg(feature = "azalea-buf")]
@@ -95,7 +97,7 @@ impl Suggestion {
}
impl SuggestionValue {
- pub fn cmp_ignore_case(&self, other: &Self) -> std::cmp::Ordering {
+ pub fn cmp_ignore_case(&self, other: &Self) -> Ordering {
match (self, other) {
(SuggestionValue::Text(a), SuggestionValue::Text(b)) => {
a.to_lowercase().cmp(&b.to_lowercase())
@@ -120,7 +122,7 @@ impl Display for SuggestionValue {
}
impl Ord for SuggestionValue {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(SuggestionValue::Text(a), SuggestionValue::Text(b)) => a.cmp(b),
(SuggestionValue::Integer(a), SuggestionValue::Integer(b)) => a.cmp(b),
@@ -133,14 +135,14 @@ impl Ord for SuggestionValue {
}
}
impl PartialOrd for SuggestionValue {
- fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(feature = "azalea-buf")]
impl AzaleaWrite for Suggestion {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.value.to_string().azalea_write(buf)?;
self.tooltip
.clone()
diff --git a/azalea-brigadier/src/suggestion/suggestions.rs b/azalea-brigadier/src/suggestion/suggestions.rs
index 60eaa111..7f04d9d7 100644
--- a/azalea-brigadier/src/suggestion/suggestions.rs
+++ b/azalea-brigadier/src/suggestion/suggestions.rs
@@ -1,6 +1,6 @@
#[cfg(feature = "azalea-buf")]
use std::io::{Cursor, Write};
-use std::{collections::HashSet, hash::Hash};
+use std::{collections::HashSet, hash::Hash, io};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
@@ -107,7 +107,7 @@ impl AzaleaRead for Suggestions {
#[cfg(feature = "azalea-buf")]
impl AzaleaWrite for Suggestions {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(self.range.start() as u32).azalea_write_var(buf)?;
(self.range.length() as u32).azalea_write_var(buf)?;
self.suggestions.azalea_write(buf)?;
diff --git a/azalea-brigadier/src/tree/mod.rs b/azalea-brigadier/src/tree/mod.rs
index bf53b4ff..993b0698 100644
--- a/azalea-brigadier/src/tree/mod.rs
+++ b/azalea-brigadier/src/tree/mod.rs
@@ -1,7 +1,7 @@
use std::{
collections::{BTreeMap, HashMap},
- fmt::Debug,
- hash::Hash,
+ fmt::{self, Debug},
+ hash::{Hash, Hasher},
ptr,
sync::Arc,
};
@@ -236,7 +236,7 @@ impl<S> CommandNode<S> {
}
impl<S> Debug for CommandNode<S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CommandNode")
// .field("value", &self.value)
.field("children", &self.children)
@@ -268,7 +268,7 @@ impl<S> Default for CommandNode<S> {
}
impl<S> Hash for CommandNode<S> {
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ fn hash<H: Hasher>(&self, state: &mut H) {
// hash the children
for (k, v) in &self.children {
k.hash(state);
diff --git a/azalea-brigadier/tests/bevy_app_usage.rs b/azalea-brigadier/tests/bevy_app_usage.rs
index e962d7d1..4520595a 100644
--- a/azalea-brigadier/tests/bevy_app_usage.rs
+++ b/azalea-brigadier/tests/bevy_app_usage.rs
@@ -1,4 +1,4 @@
-use std::{ops::Deref, sync::Arc};
+use std::{mem, ops::Deref, sync::Arc};
use azalea_brigadier::prelude::*;
use bevy_app::App;
@@ -172,7 +172,7 @@ impl WorldAccessor {
/// Swap the internal [`World`] with the given one.
fn swap(&mut self, world: &mut World) {
- std::mem::swap(&mut *self.lock(), world);
+ mem::swap(&mut *self.lock(), world);
}
}
diff --git a/azalea-brigadier/tests/suggestion/suggestions_test.rs b/azalea-brigadier/tests/suggestion/suggestions_test.rs
index 987dfb71..0da9febc 100644
--- a/azalea-brigadier/tests/suggestion/suggestions_test.rs
+++ b/azalea-brigadier/tests/suggestion/suggestions_test.rs
@@ -17,7 +17,7 @@ fn merge_single() {
StringRange::at(5),
vec![Suggestion::new(StringRange::at(5), "ar")],
);
- let merged = Suggestions::merge("foo b", &[suggestions.clone()]);
+ let merged = Suggestions::merge("foo b", std::slice::from_ref(&suggestions));
assert_eq!(merged, suggestions);
}
diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs
index b1b95f4d..143190b5 100644
--- a/azalea-buf/src/read.rs
+++ b/azalea-buf/src/read.rs
@@ -2,7 +2,7 @@ use std::{
backtrace::Backtrace,
collections::HashMap,
hash::Hash,
- io::{Cursor, Read},
+ io::{self, Cursor, Read},
sync::Arc,
};
@@ -30,7 +30,7 @@ pub enum BufReadError {
Io {
#[from]
#[backtrace]
- source: std::io::Error,
+ source: io::Error,
},
#[error("Invalid UTF-8: {bytes:?} (lossy: {lossy:?})")]
InvalidUtf8 {
diff --git a/azalea-buf/src/serializable_uuid.rs b/azalea-buf/src/serializable_uuid.rs
index 10e57eeb..76737034 100644
--- a/azalea-buf/src/serializable_uuid.rs
+++ b/azalea-buf/src/serializable_uuid.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use uuid::Uuid;
@@ -46,7 +46,7 @@ impl AzaleaRead for Uuid {
}
impl AzaleaWrite for Uuid {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let [a, b, c, d] = self.to_int_array();
a.azalea_write(buf)?;
b.azalea_write(buf)?;
diff --git a/azalea-buf/src/write.rs b/azalea-buf/src/write.rs
index 0f35dba8..a925647d 100644
--- a/azalea-buf/src/write.rs
+++ b/azalea-buf/src/write.rs
@@ -8,7 +8,7 @@ use byteorder::{BigEndian, WriteBytesExt};
use super::{MAX_STRING_LENGTH, UnsizedByteArray};
-fn write_utf_with_len(buf: &mut impl Write, string: &str, len: usize) -> Result<(), io::Error> {
+fn write_utf_with_len(buf: &mut impl Write, string: &str, len: usize) -> io::Result<()> {
if string.len() > len {
panic!(
"String too big (was {} bytes encoded, max {})",
@@ -21,21 +21,21 @@ fn write_utf_with_len(buf: &mut impl Write, string: &str, len: usize) -> Result<
}
pub trait AzaleaWrite {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error>;
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()>;
}
pub trait AzaleaWriteVar {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error>;
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()>;
}
impl AzaleaWrite for i32 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
WriteBytesExt::write_i32::<BigEndian>(buf, *self)
}
}
impl AzaleaWriteVar for i32 {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
let mut buffer = [0];
let mut value = *self;
if value == 0 {
@@ -54,24 +54,24 @@ impl AzaleaWriteVar for i32 {
}
impl AzaleaWrite for UnsizedByteArray {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
buf.write_all(self)
}
}
impl<T: AzaleaWrite> AzaleaWrite for Vec<T> {
- default fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ default fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self[..].azalea_write(buf)
}
}
impl<T: AzaleaWrite> AzaleaWrite for Box<[T]> {
- default fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ default fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self[..].azalea_write(buf)
}
}
impl<T: AzaleaWrite> AzaleaWrite for [T] {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(self.len() as u32).azalea_write_var(buf)?;
for item in self {
T::azalea_write(item, buf)?;
@@ -81,7 +81,7 @@ impl<T: AzaleaWrite> AzaleaWrite for [T] {
}
impl<K: AzaleaWrite, V: AzaleaWrite> AzaleaWrite for HashMap<K, V> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
u32::azalea_write_var(&(self.len() as u32), buf)?;
for (key, value) in self {
key.azalea_write(buf)?;
@@ -93,7 +93,7 @@ impl<K: AzaleaWrite, V: AzaleaWrite> AzaleaWrite for HashMap<K, V> {
}
impl<K: AzaleaWrite, V: AzaleaWriteVar> AzaleaWriteVar for HashMap<K, V> {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
u32::azalea_write_var(&(self.len() as u32), buf)?;
for (key, value) in self {
key.azalea_write(buf)?;
@@ -105,38 +105,38 @@ impl<K: AzaleaWrite, V: AzaleaWriteVar> AzaleaWriteVar for HashMap<K, V> {
}
impl AzaleaWrite for Vec<u8> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(self.len() as u32).azalea_write_var(buf)?;
buf.write_all(self)
}
}
impl AzaleaWrite for String {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
write_utf_with_len(buf, self, MAX_STRING_LENGTH.into())
}
}
impl AzaleaWrite for &str {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
write_utf_with_len(buf, self, MAX_STRING_LENGTH.into())
}
}
impl AzaleaWrite for u32 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
i32::azalea_write(&(*self as i32), buf)
}
}
impl AzaleaWriteVar for u32 {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
i32::azalea_write_var(&(*self as i32), buf)
}
}
impl AzaleaWriteVar for i64 {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
let mut buffer = [0];
let mut value = *self;
if value == 0 {
@@ -155,25 +155,25 @@ impl AzaleaWriteVar for i64 {
}
impl AzaleaWriteVar for u64 {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
i64::azalea_write_var(&(*self as i64), buf)
}
}
impl AzaleaWrite for u16 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
i16::azalea_write(&(*self as i16), buf)
}
}
impl AzaleaWriteVar for u16 {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
i32::azalea_write_var(&(*self as i32), buf)
}
}
impl<T: AzaleaWriteVar> AzaleaWriteVar for [T] {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
u32::azalea_write_var(&(self.len() as u32), buf)?;
for i in self {
i.azalea_write_var(buf)?;
@@ -182,67 +182,67 @@ impl<T: AzaleaWriteVar> AzaleaWriteVar for [T] {
}
}
impl<T: AzaleaWriteVar> AzaleaWriteVar for Vec<T> {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
self[..].azalea_write_var(buf)
}
}
impl<T: AzaleaWriteVar> AzaleaWriteVar for Box<[T]> {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
self[..].azalea_write_var(buf)
}
}
impl AzaleaWrite for u8 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
WriteBytesExt::write_u8(buf, *self)
}
}
impl AzaleaWrite for i16 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
WriteBytesExt::write_i16::<BigEndian>(buf, *self)
}
}
impl AzaleaWrite for i64 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
WriteBytesExt::write_i64::<BigEndian>(buf, *self)
}
}
impl AzaleaWrite for u64 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
i64::azalea_write(&(*self as i64), buf)
}
}
impl AzaleaWrite for bool {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let byte = u8::from(*self);
byte.azalea_write(buf)
}
}
impl AzaleaWrite for i8 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(*self as u8).azalea_write(buf)
}
}
impl AzaleaWrite for f32 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
WriteBytesExt::write_f32::<BigEndian>(buf, *self)
}
}
impl AzaleaWrite for f64 {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
WriteBytesExt::write_f64::<BigEndian>(buf, *self)
}
}
impl<T: AzaleaWrite> AzaleaWrite for Option<T> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
if let Some(s) = self {
true.azalea_write(buf)?;
s.azalea_write(buf)?;
@@ -254,7 +254,7 @@ impl<T: AzaleaWrite> AzaleaWrite for Option<T> {
}
impl<T: AzaleaWriteVar> AzaleaWriteVar for Option<T> {
- fn azalea_write_var(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> {
if let Some(s) = self {
true.azalea_write(buf)?;
s.azalea_write_var(buf)?;
@@ -267,7 +267,7 @@ impl<T: AzaleaWriteVar> AzaleaWriteVar for Option<T> {
// [T; N]
impl<T: AzaleaWrite, const N: usize> AzaleaWrite for [T; N] {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
for i in self {
i.azalea_write(buf)?;
}
@@ -276,7 +276,7 @@ impl<T: AzaleaWrite, const N: usize> AzaleaWrite for [T; N] {
}
impl AzaleaWrite for simdnbt::owned::NbtTag {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut data = Vec::new();
self.write(&mut data);
buf.write_all(&data)
@@ -284,7 +284,7 @@ impl AzaleaWrite for simdnbt::owned::NbtTag {
}
impl AzaleaWrite for simdnbt::owned::NbtCompound {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut data = Vec::new();
simdnbt::owned::NbtTag::Compound(self.clone()).write(&mut data);
buf.write_all(&data)
@@ -292,7 +292,7 @@ impl AzaleaWrite for simdnbt::owned::NbtCompound {
}
impl AzaleaWrite for simdnbt::owned::Nbt {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut data = Vec::new();
self.write_unnamed(&mut data);
buf.write_all(&data)
@@ -303,20 +303,20 @@ impl<T> AzaleaWrite for Box<T>
where
T: AzaleaWrite,
{
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
T::azalea_write(&**self, buf)
}
}
impl<A: AzaleaWrite, B: AzaleaWrite> AzaleaWrite for (A, B) {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.0.azalea_write(buf)?;
self.1.azalea_write(buf)
}
}
impl<T: AzaleaWrite> AzaleaWrite for Arc<T> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
T::azalea_write(&**self, buf)
}
}
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 8eaaf178..c04aac4e 100644
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -1,4 +1,8 @@
-use std::{fmt::Display, sync::LazyLock};
+use std::{
+ fmt::{self, Display},
+ io::{self, Cursor, Write},
+ sync::LazyLock,
+};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
@@ -269,13 +273,12 @@ impl<'de> Deserialize<'de> for FormattedText {
// string to with_array otherwise add the component
// to the array
let c = FormattedText::deserialize(item).map_err(de::Error::custom)?;
- if let FormattedText::Text(text_component) = c {
- if text_component.base.siblings.is_empty()
- && text_component.base.style.is_empty()
- {
- with_array.push(StringOrComponent::String(text_component.text));
- continue;
- }
+ if let FormattedText::Text(text_component) = c
+ && text_component.base.siblings.is_empty()
+ && text_component.base.style.is_empty()
+ {
+ with_array.push(StringOrComponent::String(text_component.text));
+ continue;
}
with_array.push(StringOrComponent::FormattedText(
FormattedText::deserialize(item).map_err(de::Error::custom)?,
@@ -465,13 +468,12 @@ impl FormattedText {
with_array.push(StringOrComponent::String("?".to_string()));
}
} else if let Some(c) = FormattedText::from_nbt_compound(item) {
- if let FormattedText::Text(text_component) = c {
- if text_component.base.siblings.is_empty()
- && text_component.base.style.is_empty()
- {
- with_array.push(StringOrComponent::String(text_component.text));
- continue;
- }
+ if let FormattedText::Text(text_component) = c
+ && text_component.base.siblings.is_empty()
+ && text_component.base.style.is_empty()
+ {
+ with_array.push(StringOrComponent::String(text_component.text));
+ continue;
}
with_array.push(StringOrComponent::FormattedText(
FormattedText::from_nbt_compound(item)?,
@@ -547,7 +549,7 @@ impl From<&simdnbt::Mutf8Str> for FormattedText {
#[cfg(feature = "azalea-buf")]
#[cfg(feature = "simdnbt")]
impl AzaleaRead for FormattedText {
- fn azalea_read(buf: &mut std::io::Cursor<&[u8]>) -> Result<Self, BufReadError> {
+ fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
let nbt = simdnbt::borrow::read_optional_tag(buf)?;
match nbt {
Some(nbt) => FormattedText::from_nbt_tag(nbt.as_tag()).ok_or(BufReadError::Custom(
@@ -561,7 +563,7 @@ impl AzaleaRead for FormattedText {
#[cfg(feature = "azalea-buf")]
#[cfg(feature = "simdnbt")]
impl AzaleaWrite for FormattedText {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut out = Vec::new();
simdnbt::owned::BaseNbt::write_unnamed(&(self.clone().to_compound().into()), &mut out);
buf.write_all(&out)
@@ -583,7 +585,7 @@ impl From<&str> for FormattedText {
}
impl Display for FormattedText {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FormattedText::Text(c) => c.fmt(f),
FormattedText::Translatable(c) => c.fmt(f),
diff --git a/azalea-chat/src/numbers.rs b/azalea-chat/src/numbers.rs
index 161f1177..d9499e26 100644
--- a/azalea-chat/src/numbers.rs
+++ b/azalea-chat/src/numbers.rs
@@ -1,7 +1,7 @@
//! Contains a few ways to style numbers. At the time of writing, Minecraft only
//! uses this for rendering scoreboard objectives.
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{AzaleaRead, AzaleaWrite};
@@ -35,7 +35,7 @@ impl AzaleaRead for NumberFormat {
#[cfg(feature = "azalea-buf")]
impl AzaleaWrite for NumberFormat {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
NumberFormat::Blank => NumberFormatKind::Blank.azalea_write(buf)?,
NumberFormat::Styled { style } => {
diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs
index 3d068cb9..18176a3d 100644
--- a/azalea-chat/src/style.rs
+++ b/azalea-chat/src/style.rs
@@ -595,29 +595,29 @@ impl Style {
pub fn get_html_style(&self) -> String {
let mut style = String::new();
if let Some(color) = &self.color {
- style.push_str(&format!("color: {};", color.format_value()));
+ style.push_str(&format!("color:{};", color.format_value()));
}
if let Some(bold) = self.bold {
style.push_str(&format!(
- "font-weight: {};",
+ "font-weight:{};",
if bold { "bold" } else { "normal" }
));
}
if let Some(italic) = self.italic {
style.push_str(&format!(
- "font-style: {};",
+ "font-style:{};",
if italic { "italic" } else { "normal" }
));
}
if let Some(underlined) = self.underlined {
style.push_str(&format!(
- "text-decoration: {};",
+ "text-decoration:{};",
if underlined { "underline" } else { "none" }
));
}
if let Some(strikethrough) = self.strikethrough {
style.push_str(&format!(
- "text-decoration: {};",
+ "text-decoration:{};",
if strikethrough {
"line-through"
} else {
@@ -625,10 +625,10 @@ impl Style {
}
));
}
- if let Some(obfuscated) = self.obfuscated {
- if obfuscated {
- style.push_str("filter: blur(2px);");
- }
+ if let Some(obfuscated) = self.obfuscated
+ && obfuscated
+ {
+ style.push_str("filter:blur(2px);");
}
style
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs
index 62547d0d..228dad3b 100644
--- a/azalea-chat/src/text_component.rs
+++ b/azalea-chat/src/text_component.rs
@@ -1,4 +1,4 @@
-use std::fmt::Display;
+use std::fmt::{self, Display};
use serde::{__private::ser::FlatMapSerializer, Serialize, Serializer, ser::SerializeMap};
@@ -142,7 +142,7 @@ impl TextComponent {
}
impl Display for TextComponent {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// this contains the final string will all the ansi escape codes
for component in FormattedText::Text(self.clone()).into_iter() {
let component_text = match &component {
@@ -191,9 +191,9 @@ mod tests {
format!(
"{GREEN}Hypixel Network {END_SPAN}{RED}[1.8-1.18]<br>{END_SPAN}{BOLD_AQUA}HAPPY HOLIDAYS{END_SPAN}",
END_SPAN = "</span>",
- GREEN = "<span style=\"color: #55FF55;\">",
- RED = "<span style=\"color: #FF5555;\">",
- BOLD_AQUA = "<span style=\"color: #55FFFF;font-weight: bold;\">",
+ GREEN = "<span style=\"color:#55FF55;\">",
+ RED = "<span style=\"color:#FF5555;\">",
+ BOLD_AQUA = "<span style=\"color:#55FFFF;font-weight: bold;\">",
)
);
}
@@ -207,8 +207,8 @@ mod tests {
format!(
"{GREEN}&lt;b&gt;&amp;<br>{END_SPAN}{AQUA}&lt;/b&gt;{END_SPAN}",
END_SPAN = "</span>",
- GREEN = "<span style=\"color: #55FF55;\">",
- AQUA = "<span style=\"color: #55FFFF;\">",
+ GREEN = "<span style=\"color:#55FF55;\">",
+ AQUA = "<span style=\"color:#55FFFF;\">",
)
);
}
diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs
index 452de738..431c08b2 100644
--- a/azalea-chat/src/translatable_component.rs
+++ b/azalea-chat/src/translatable_component.rs
@@ -1,4 +1,4 @@
-use std::fmt::{self, Display, Formatter};
+use std::fmt::{self, Display};
use serde::{__private::ser::FlatMapSerializer, Serialize, Serializer, ser::SerializeMap};
#[cfg(feature = "simdnbt")]
@@ -189,7 +189,7 @@ impl TranslatableComponent {
}
impl Display for TranslatableComponent {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// this contains the final string will all the ansi escape codes
for component in FormattedText::Translatable(self.clone()).into_iter() {
let component_text = match &component {
@@ -208,7 +208,7 @@ impl Display for TranslatableComponent {
}
impl Display for StringOrComponent {
- fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
StringOrComponent::String(s) => write!(f, "{s}"),
StringOrComponent::FormattedText(c) => write!(f, "{c}"),
diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs
index 77be68a8..e6bef25f 100644
--- a/azalea-client/src/entity_query.rs
+++ b/azalea-client/src/entity_query.rs
@@ -1,4 +1,4 @@
-use std::sync::Arc;
+use std::{any, sync::Arc};
use bevy_ecs::{
component::Component,
@@ -29,7 +29,7 @@ impl Client {
.unwrap_or_else(|_| {
panic!(
"Our client is missing a required component {:?}",
- std::any::type_name::<D>()
+ any::type_name::<D>()
)
})
}
@@ -77,7 +77,7 @@ impl Client {
let components = q.get(&ecs, entity).unwrap_or_else(|_| {
panic!(
"Entity is missing a required component {:?}",
- std::any::type_name::<Q>()
+ any::type_name::<Q>()
)
});
components.clone()
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs
index 26e08e9b..ee318c06 100644
--- a/azalea-client/src/local_player.rs
+++ b/azalea-client/src/local_player.rs
@@ -1,4 +1,8 @@
-use std::{collections::HashMap, io, sync::Arc};
+use std::{
+ collections::HashMap,
+ error, io,
+ sync::{Arc, PoisonError},
+};
use azalea_auth::game_profile::GameProfile;
use azalea_core::game_type::GameMode;
@@ -169,13 +173,13 @@ pub enum HandlePacketError {
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
- Other(#[from] Box<dyn std::error::Error + Send + Sync>),
+ Other(#[from] Box<dyn error::Error + Send + Sync>),
#[error("{0}")]
Send(#[from] mpsc::error::SendError<AzaleaEvent>),
}
-impl<T> From<std::sync::PoisonError<T>> for HandlePacketError {
- fn from(e: std::sync::PoisonError<T>) -> Self {
+impl<T> From<PoisonError<T>> for HandlePacketError {
+ fn from(e: PoisonError<T>) -> Self {
HandlePacketError::Poison(e.to_string())
}
}
diff --git a/azalea-client/src/plugins/chat_signing.rs b/azalea-client/src/plugins/chat_signing.rs
index 9863cb3f..8961430e 100644
--- a/azalea-client/src/plugins/chat_signing.rs
+++ b/azalea-client/src/plugins/chat_signing.rs
@@ -102,10 +102,10 @@ pub fn request_certs_if_needed(
>,
) {
for (entity, account, only_refresh_certs_after, chat_signing_session) in query.iter_mut() {
- if let Some(only_refresh_certs_after) = only_refresh_certs_after {
- if only_refresh_certs_after.refresh_at > Instant::now() {
- continue;
- }
+ if let Some(only_refresh_certs_after) = only_refresh_certs_after
+ && only_refresh_certs_after.refresh_at > Instant::now()
+ {
+ continue;
}
let certs = account.certs.lock();
@@ -124,20 +124,18 @@ pub fn request_certs_if_needed(
};
drop(certs);
- if should_refresh {
- if let Some(access_token) = &account.access_token {
- let task_pool = IoTaskPool::get();
-
- let access_token = access_token.lock().clone();
- debug!("Started task to fetch certs");
- let task = task_pool.spawn(async_compat::Compat::new(async move {
- azalea_auth::certs::fetch_certificates(&access_token).await
- }));
- commands
- .entity(entity)
- .insert(RequestCertsTask(task))
- .remove::<OnlyRefreshCertsAfter>();
- }
+ if should_refresh && let Some(access_token) = &account.access_token {
+ let task_pool = IoTaskPool::get();
+
+ let access_token = access_token.lock().clone();
+ debug!("Started task to fetch certs");
+ let task = task_pool.spawn(async_compat::Compat::new(async move {
+ azalea_auth::certs::fetch_certificates(&access_token).await
+ }));
+ commands
+ .entity(entity)
+ .insert(RequestCertsTask(task))
+ .remove::<OnlyRefreshCertsAfter>();
}
}
}
diff --git a/azalea-client/src/plugins/chunks.rs b/azalea-client/src/plugins/chunks.rs
index 5e062887..8b052f63 100644
--- a/azalea-client/src/plugins/chunks.rs
+++ b/azalea-client/src/plugins/chunks.rs
@@ -84,14 +84,12 @@ pub fn handle_receive_chunk_events(
let shared_chunk = instance.chunks.get(&pos);
let this_client_has_chunk = partial_instance.chunks.limited_get(&pos).is_some();
- if !this_client_has_chunk {
- if let Some(shared_chunk) = shared_chunk {
- trace!("Skipping parsing chunk {pos:?} because we already know about it");
- partial_instance
- .chunks
- .limited_set(&pos, Some(shared_chunk));
- continue;
- }
+ if !this_client_has_chunk && let Some(shared_chunk) = shared_chunk {
+ trace!("Skipping parsing chunk {pos:?} because we already know about it");
+ partial_instance
+ .chunks
+ .limited_set(&pos, Some(shared_chunk));
+ continue;
}
let heightmaps = &event.packet.chunk_data.heightmaps;
diff --git a/azalea-client/src/plugins/inventory.rs b/azalea-client/src/plugins/inventory.rs
index 0a9c5cad..829b37f8 100644
--- a/azalea-client/src/plugins/inventory.rs
+++ b/azalea-client/src/plugins/inventory.rs
@@ -170,17 +170,17 @@ impl Inventory {
}
if let QuickCraftStatus::Add { slot } = quick_craft.status {
let slot_item = self.menu().slot(slot as usize);
- if let Some(slot_item) = slot_item {
- if let ItemStack::Present(carried) = &self.carried {
- // minecraft also checks slot.may_place(carried) and
- // menu.can_drag_to(slot)
- // but they always return true so they're not relevant for us
- if can_item_quick_replace(slot_item, &self.carried, true)
- && (self.quick_craft_kind == QuickCraftKind::Right
- || carried.count as usize > self.quick_craft_slots.len())
- {
- self.quick_craft_slots.insert(slot);
- }
+ if let Some(slot_item) = slot_item
+ && let ItemStack::Present(carried) = &self.carried
+ {
+ // minecraft also checks slot.may_place(carried) and
+ // menu.can_drag_to(slot)
+ // but they always return true so they're not relevant for us
+ if can_item_quick_replace(slot_item, &self.carried, true)
+ && (self.quick_craft_kind == QuickCraftKind::Right
+ || carried.count as usize > self.quick_craft_slots.len())
+ {
+ self.quick_craft_slots.insert(slot);
}
}
return;
@@ -468,26 +468,23 @@ impl Inventory {
for i in iterator {
if target_slot_item.count < target_slot_item.kind.max_stack_size() {
let checking_slot = self.menu().slot(i).unwrap();
- if let ItemStack::Present(checking_item) = checking_slot {
- if can_item_quick_replace(checking_slot, &target_slot, true)
- && self.menu().may_pickup(i)
- && (round != 0
- || checking_item.count
- != checking_item.kind.max_stack_size())
- {
- // get the checking_slot and checking_item again but mutable
- let checking_slot = self.menu_mut().slot_mut(i).unwrap();
-
- let taken_item =
- checking_slot.split(checking_slot.count() as u32);
-
- // now extend the carried item
- let target_slot = &mut self.carried;
- let ItemStack::Present(target_slot_item) = target_slot else {
- unreachable!("target slot is not empty but is not present");
- };
- target_slot_item.count += taken_item.count();
- }
+ if let ItemStack::Present(checking_item) = checking_slot
+ && can_item_quick_replace(checking_slot, &target_slot, true)
+ && self.menu().may_pickup(i)
+ && (round != 0
+ || checking_item.count != checking_item.kind.max_stack_size())
+ {
+ // get the checking_slot and checking_item again but mutable
+ let checking_slot = self.menu_mut().slot_mut(i).unwrap();
+
+ let taken_item = checking_slot.split(checking_slot.count() as u32);
+
+ // now extend the carried item
+ let target_slot = &mut self.carried;
+ let ItemStack::Present(target_slot_item) = target_slot else {
+ unreachable!("target slot is not empty but is not present");
+ };
+ target_slot_item.count += taken_item.count();
}
}
}
diff --git a/azalea-client/src/plugins/join.rs b/azalea-client/src/plugins/join.rs
index e31c64c4..a3447782 100644
--- a/azalea-client/src/plugins/join.rs
+++ b/azalea-client/src/plugins/join.rs
@@ -96,20 +96,20 @@ pub fn handle_start_join_server_event(
debug!("Reusing entity {entity:?} for client");
// check if it's already connected
- if let Ok(conn) = connection_query.get(entity) {
- if conn.is_alive() {
- if let Some(start_join_callback_tx) = &event.start_join_callback_tx {
- warn!(
- "Received StartJoinServerEvent for {entity:?} but it's already connected. Ignoring the event but replying with Ok."
- );
- let _ = start_join_callback_tx.0.send(Ok(entity));
- } else {
- warn!(
- "Received StartJoinServerEvent for {entity:?} but it's already connected. Ignoring the event."
- );
- }
- return;
+ if let Ok(conn) = connection_query.get(entity)
+ && conn.is_alive()
+ {
+ if let Some(start_join_callback_tx) = &event.start_join_callback_tx {
+ warn!(
+ "Received StartJoinServerEvent for {entity:?} but it's already connected. Ignoring the event but replying with Ok."
+ );
+ let _ = start_join_callback_tx.0.send(Ok(entity));
+ } else {
+ warn!(
+ "Received StartJoinServerEvent for {entity:?} but it's already connected. Ignoring the event."
+ );
}
+ return;
}
entity
diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs
index 2d844064..95fdeb6e 100644
--- a/azalea-client/src/plugins/movement.rs
+++ b/azalea-client/src/plugins/movement.rs
@@ -1,4 +1,5 @@
use std::backtrace::Backtrace;
+use std::io;
use azalea_core::position::Vec3;
use azalea_core::tick::GameTick;
@@ -28,7 +29,7 @@ pub enum MovePlayerError {
#[error("Player is not in world")]
PlayerNotInWorld(Backtrace),
#[error("{0}")]
- Io(#[from] std::io::Error),
+ Io(#[from] io::Error),
}
impl From<MoveEntityError> for MovePlayerError {
diff --git a/azalea-client/tests/reply_to_ping_with_pong.rs b/azalea-client/tests/reply_to_ping_with_pong.rs
index d921c905..bc8bccd4 100644
--- a/azalea-client/tests/reply_to_ping_with_pong.rs
+++ b/azalea-client/tests/reply_to_ping_with_pong.rs
@@ -28,11 +28,11 @@ fn reply_to_ping_with_pong() {
simulation
.app
.add_observer(move |trigger: Trigger<SendConfigPacketEvent>| {
- if trigger.sent_by == simulation.entity {
- if let ServerboundConfigPacket::Pong(packet) = &trigger.packet {
- assert_eq!(packet.id, 321);
- *reply_count_clone.lock() += 1;
- }
+ if trigger.sent_by == simulation.entity
+ && let ServerboundConfigPacket::Pong(packet) = &trigger.packet
+ {
+ assert_eq!(packet.id, 321);
+ *reply_count_clone.lock() += 1;
}
});
@@ -63,11 +63,11 @@ fn reply_to_ping_with_pong() {
simulation
.app
.add_observer(move |trigger: Trigger<SendPacketEvent>| {
- if trigger.sent_by == simulation.entity {
- if let ServerboundGamePacket::Pong(packet) = &trigger.packet {
- assert_eq!(packet.id, 123);
- *reply_count_clone.lock() += 1;
- }
+ if trigger.sent_by == simulation.entity
+ && let ServerboundGamePacket::Pong(packet) = &trigger.packet
+ {
+ assert_eq!(packet.id, 123);
+ *reply_count_clone.lock() += 1;
}
});
diff --git a/azalea-core/src/bitset.rs b/azalea-core/src/bitset.rs
index 715c57fb..ccc43ba0 100644
--- a/azalea-core/src/bitset.rs
+++ b/azalea-core/src/bitset.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
@@ -177,7 +177,7 @@ impl<const N: usize> AzaleaWrite for FixedBitSet<N>
where
[u8; bits_to_bytes(N)]: Sized,
{
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
for i in 0..bits_to_bytes(N) {
self.data[i].azalea_write(buf)?;
}
diff --git a/azalea-core/src/difficulty.rs b/azalea-core/src/difficulty.rs
index b907bbb3..f82f0e9d 100644
--- a/azalea-core/src/difficulty.rs
+++ b/azalea-core/src/difficulty.rs
@@ -1,6 +1,6 @@
use std::{
- fmt::{Debug, Error, Formatter},
- io::{Cursor, Write},
+ fmt::{self, Debug},
+ io::{self, Cursor, Write},
};
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
@@ -18,7 +18,7 @@ pub enum Err {
}
impl Debug for Err {
- fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Err::InvalidDifficulty(s) => write!(f, "Invalid difficulty: {s}"),
}
@@ -73,7 +73,7 @@ impl AzaleaRead for Difficulty {
}
impl AzaleaWrite for Difficulty {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
u8::azalea_write(&self.id(), buf)
}
}
diff --git a/azalea-core/src/filterable.rs b/azalea-core/src/filterable.rs
index 70b0d6f7..1c432b28 100644
--- a/azalea-core/src/filterable.rs
+++ b/azalea-core/src/filterable.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaRead, AzaleaReadLimited, AzaleaReadVar, AzaleaWrite};
@@ -9,7 +9,7 @@ pub struct Filterable<T> {
}
impl<T: AzaleaWrite> azalea_buf::AzaleaWrite for Filterable<T> {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.raw.azalea_write(buf)?;
self.filtered.azalea_write(buf)?;
Ok(())
diff --git a/azalea-core/src/game_type.rs b/azalea-core/src/game_type.rs
index 5d9ee8f5..7328902a 100644
--- a/azalea-core/src/game_type.rs
+++ b/azalea-core/src/game_type.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, BufReadError};
use azalea_chat::translatable_component::TranslatableComponent;
@@ -108,7 +108,7 @@ impl AzaleaRead for GameMode {
}
impl AzaleaWrite for GameMode {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
u8::azalea_write(&self.to_id(), buf)
}
}
@@ -138,7 +138,7 @@ impl AzaleaRead for OptionalGameType {
}
impl AzaleaWrite for OptionalGameType {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
GameMode::to_optional_id(*self).azalea_write(buf)
}
}
diff --git a/azalea-core/src/objectives.rs b/azalea-core/src/objectives.rs
index a2f0d517..be5ea252 100644
--- a/azalea-core/src/objectives.rs
+++ b/azalea-core/src/objectives.rs
@@ -1,5 +1,5 @@
use std::{
- fmt::{self, Display, Formatter},
+ fmt::{self, Display},
str::FromStr,
};
@@ -12,7 +12,7 @@ pub enum ObjectiveCriteria {
}
impl Display for ObjectiveCriteria {
- fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ObjectiveCriteria::Integer => write!(f, "integer"),
ObjectiveCriteria::Hearts => write!(f, "hearts"),
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index e82e5e4a..ea3df79b 100644
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -3,6 +3,8 @@
//! The most common ones are [`Vec3`] and [`BlockPos`], which are usually used
//! for entity positions and block positions, respectively.
+use std::hash::Hasher;
+use std::io;
use std::str::FromStr;
use std::{
fmt,
@@ -477,7 +479,7 @@ impl AzaleaRead for ChunkPos {
}
}
impl AzaleaWrite for ChunkPos {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
u64::from(*self).azalea_write(buf)?;
Ok(())
}
@@ -485,7 +487,7 @@ impl AzaleaWrite for ChunkPos {
impl Hash for ChunkPos {
#[inline]
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ fn hash<H: Hasher>(&self, state: &mut H) {
// optimized hash that only calls hash once
u64::from(*self).hash(state);
}
@@ -526,7 +528,7 @@ impl ChunkBlockPos {
impl Hash for ChunkBlockPos {
// optimized hash that only calls hash once
#[inline]
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ fn hash<H: Hasher>(&self, state: &mut H) {
u64::from(*self).hash(state);
}
}
@@ -570,7 +572,7 @@ impl Add<ChunkSectionBlockPos> for ChunkSectionPos {
impl Hash for ChunkSectionBlockPos {
// optimized hash that only calls hash once
#[inline]
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ fn hash<H: Hasher>(&self, state: &mut H) {
u16::from(*self).hash(state);
}
}
@@ -782,7 +784,7 @@ impl AzaleaRead for ChunkSectionPos {
}
impl AzaleaWrite for BlockPos {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut val: u64 = 0;
val |= ((self.x as u64) & PACKED_X_MASK) << X_OFFSET;
val |= (self.y as u64) & PACKED_Y_MASK;
@@ -792,7 +794,7 @@ impl AzaleaWrite for BlockPos {
}
impl AzaleaWrite for GlobalPos {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
ResourceLocation::azalea_write(&self.world, buf)?;
BlockPos::azalea_write(&self.pos, buf)?;
@@ -801,7 +803,7 @@ impl AzaleaWrite for GlobalPos {
}
impl AzaleaWrite for ChunkSectionPos {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let long = (((self.x & 0x3FFFFF) as i64) << 42)
| (self.y & 0xFFFFF) as i64
| (((self.z & 0x3FFFFF) as i64) << 20);
diff --git a/azalea-core/src/resource_location.rs b/azalea-core/src/resource_location.rs
index 0b21a43b..a4309035 100644
--- a/azalea-core/src/resource_location.rs
+++ b/azalea-core/src/resource_location.rs
@@ -2,7 +2,7 @@
use std::{
fmt,
- io::{Cursor, Write},
+ io::{self, Cursor, Write},
str::FromStr,
};
@@ -67,7 +67,7 @@ impl AzaleaRead for ResourceLocation {
}
}
impl AzaleaWrite for ResourceLocation {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.to_string().azalea_write(buf)
}
}
diff --git a/azalea-entity/src/data.rs b/azalea-entity/src/data.rs
index c92d1c95..24e31713 100644
--- a/azalea-entity/src/data.rs
+++ b/azalea-entity/src/data.rs
@@ -1,6 +1,6 @@
//! Define some types needed for entity metadata.
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_chat::FormattedText;
@@ -43,7 +43,7 @@ impl AzaleaRead for EntityMetadataItems {
}
impl AzaleaWrite for EntityMetadataItems {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
for item in &self.0 {
item.index.azalea_write(buf)?;
item.value.azalea_write(buf)?;
@@ -128,7 +128,7 @@ impl AzaleaRead for OptionalUnsignedInt {
}
}
impl AzaleaWrite for OptionalUnsignedInt {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self.0 {
Some(val) => (val + 1).azalea_write_var(buf),
None => 0u32.azalea_write_var(buf),
diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs
index 0f49039e..44a4a9ee 100644
--- a/azalea-entity/src/lib.rs
+++ b/azalea-entity/src/lib.rs
@@ -12,7 +12,7 @@ mod plugin;
pub mod vec_delta_codec;
use std::{
- fmt::Debug,
+ fmt::{self, Debug},
hash::{Hash, Hasher},
};
@@ -133,7 +133,7 @@ impl EntityUuid {
}
}
impl Debug for EntityUuid {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(self.0).fmt(f)
}
}
diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs
index 0f1e036e..2fc89e84 100644
--- a/azalea-entity/src/plugin/indexing.rs
+++ b/azalea-entity/src/plugin/indexing.rs
@@ -2,7 +2,7 @@
use std::{
collections::{HashMap, HashSet},
- fmt::Debug,
+ fmt::{self, Debug},
};
use azalea_core::position::ChunkPos;
@@ -115,7 +115,7 @@ impl EntityIdIndex {
}
impl Debug for EntityUuidIndex {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EntityUuidIndex").finish()
}
}
diff --git a/azalea-inventory/src/components.rs b/azalea-inventory/src/components.rs
index 9e0a37b0..72216475 100644
--- a/azalea-inventory/src/components.rs
+++ b/azalea-inventory/src/components.rs
@@ -1,5 +1,9 @@
use core::f64;
-use std::{any::Any, collections::HashMap, io::Cursor};
+use std::{
+ any::Any,
+ collections::HashMap,
+ io::{self, Cursor},
+};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
use azalea_chat::FormattedText;
@@ -23,11 +27,11 @@ pub trait DataComponent: Send + Sync + Any {
}
pub trait EncodableDataComponent: Send + Sync + Any {
- fn encode(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error>;
+ fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()>;
// using the Clone trait makes it not be object-safe, so we have our own clone
// function instead
fn clone(&self) -> Box<dyn EncodableDataComponent>;
- // same deal here
+ // same thing here
fn eq(&self, other: Box<dyn EncodableDataComponent>) -> bool;
}
@@ -35,7 +39,7 @@ impl<T> EncodableDataComponent for T
where
T: DataComponent + Clone + AzaleaWrite + AzaleaRead + PartialEq,
{
- fn encode(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
+ fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> {
self.azalea_write(buf)
}
fn clone(&self) -> Box<dyn EncodableDataComponent> {
diff --git a/azalea-inventory/src/slot.rs b/azalea-inventory/src/slot.rs
index e2e84a68..c48d9488 100644
--- a/azalea-inventory/src/slot.rs
+++ b/azalea-inventory/src/slot.rs
@@ -1,7 +1,7 @@
use std::{
any::Any,
fmt,
- io::{Cursor, Write},
+ io::{self, Cursor, Write},
};
use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
@@ -73,10 +73,10 @@ impl ItemStack {
/// Update whether this slot is empty, based on the count.
pub fn update_empty(&mut self) {
- if let ItemStack::Present(i) = self {
- if i.is_empty() {
- *self = ItemStack::Empty;
- }
+ if let ItemStack::Present(i) = self
+ && i.is_empty()
+ {
+ *self = ItemStack::Empty;
}
}
@@ -159,7 +159,7 @@ impl AzaleaRead for ItemStack {
}
impl AzaleaWrite for ItemStack {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
ItemStack::Empty => 0_i32.azalea_write_var(buf)?,
ItemStack::Present(i) => {
@@ -256,7 +256,7 @@ impl AzaleaRead for DataComponentPatch {
}
impl AzaleaWrite for DataComponentPatch {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut components_with_data_count: u32 = 0;
let mut components_without_data_count: u32 = 0;
for component in self.components.values() {
diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs
index e557b028..e7d203d8 100644
--- a/azalea-physics/src/clip.rs
+++ b/azalea-physics/src/clip.rs
@@ -151,12 +151,11 @@ fn clip_with_interaction_override(
// compostors, hoppers, and scaffolding.
let interaction_shape = &*EMPTY_SHAPE;
let interaction_hit_result = interaction_shape.clip(from, to, block_pos);
- if let Some(interaction_hit_result) = interaction_hit_result {
- if interaction_hit_result.location.distance_squared_to(from)
+ if let Some(interaction_hit_result) = interaction_hit_result
+ && interaction_hit_result.location.distance_squared_to(from)
< block_hit_result.location.distance_squared_to(from)
- {
- return Some(block_hit_result.with_direction(interaction_hit_result.direction));
- }
+ {
+ return Some(block_hit_result.with_direction(interaction_hit_result.direction));
}
Some(block_hit_result)
diff --git a/azalea-physics/src/collision/discrete_voxel_shape.rs b/azalea-physics/src/collision/discrete_voxel_shape.rs
index cacbc987..a56c8085 100644
--- a/azalea-physics/src/collision/discrete_voxel_shape.rs
+++ b/azalea-physics/src/collision/discrete_voxel_shape.rs
@@ -1,3 +1,5 @@
+use std::cmp;
+
use azalea_core::{
bitset::BitSet,
direction::{Axis, AxisCycle},
@@ -146,12 +148,12 @@ impl BitSetDiscreteVoxelShape {
fn fill_update_bounds(&mut self, x: u32, y: u32, z: u32, update: bool) {
self.storage.set(self.get_index(x, y, z));
if update {
- self.x_min = std::cmp::min(self.x_min, x as i32);
- self.y_min = std::cmp::min(self.y_min, y as i32);
- self.z_min = std::cmp::min(self.z_min, z as i32);
- self.x_max = std::cmp::max(self.x_max, (x + 1) as i32);
- self.y_max = std::cmp::max(self.y_max, (y + 1) as i32);
- self.z_max = std::cmp::max(self.z_max, (z + 1) as i32);
+ self.x_min = cmp::min(self.x_min, x as i32);
+ self.y_min = cmp::min(self.y_min, y as i32);
+ self.z_min = cmp::min(self.z_min, z as i32);
+ self.x_max = cmp::max(self.x_max, (x + 1) as i32);
+ self.y_max = cmp::max(self.y_max, (y + 1) as i32);
+ self.z_max = cmp::max(self.z_max, (z + 1) as i32);
}
}
@@ -201,24 +203,24 @@ impl BitSetDiscreteVoxelShape {
var12.try_into().unwrap(),
var14.try_into().unwrap(),
));
- var7[2] = std::cmp::min(var7[2], var14);
- var7[5] = std::cmp::max(var7[5], var14);
+ var7[2] = cmp::min(var7[2], var14);
+ var7[5] = cmp::max(var7[5], var14);
var13[0] = true;
}
true
});
if var13[0] {
- var7[1] = std::cmp::min(var7[1], var12);
- var7[4] = std::cmp::max(var7[4], var12);
+ var7[1] = cmp::min(var7[1], var12);
+ var7[4] = cmp::max(var7[4], var12);
var10[0] = true;
}
true
});
if var10[0] {
- var7[0] = std::cmp::min(var7[0], var9);
- var7[3] = std::cmp::max(var7[3], var9);
+ var7[0] = cmp::min(var7[0], var9);
+ var7[3] = cmp::max(var7[3], var9);
}
true
diff --git a/azalea-protocol/azalea-protocol-macros/src/lib.rs b/azalea-protocol/azalea-protocol-macros/src/lib.rs
index a1255519..c11dd6d5 100644
--- a/azalea-protocol/azalea-protocol-macros/src/lib.rs
+++ b/azalea-protocol/azalea-protocol-macros/src/lib.rs
@@ -23,7 +23,7 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
let contents = quote! {
impl #ident {
- pub fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ pub fn write(&self, buf: &mut impl std::io::Write) -> std::io::Result<()> {
azalea_buf::AzaleaWrite::azalea_write(self, buf)
}
@@ -361,7 +361,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
}
}
- fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn write(&self, buf: &mut impl std::io::Write) -> std::io::Result<()> {
match self {
#serverbound_write_match_contents
}
@@ -405,7 +405,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
}
}
- fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn write(&self, buf: &mut impl std::io::Write) -> std::io::Result<()> {
match self {
#clientbound_write_match_contents
}
diff --git a/azalea-protocol/src/common/client_information.rs b/azalea-protocol/src/common/client_information.rs
index 6f5e05e2..690d052a 100644
--- a/azalea-protocol/src/common/client_information.rs
+++ b/azalea-protocol/src/common/client_information.rs
@@ -1,3 +1,5 @@
+use std::io::{self, Cursor};
+
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite};
use azalea_core::bitset::FixedBitSet;
use bevy_ecs::component::Component;
@@ -96,7 +98,7 @@ impl Default for ModelCustomization {
}
impl AzaleaRead for ModelCustomization {
- fn azalea_read(buf: &mut std::io::Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
+ fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
let set = FixedBitSet::<7>::azalea_read(buf)?;
Ok(Self {
cape: set.index(0),
@@ -111,7 +113,7 @@ impl AzaleaRead for ModelCustomization {
}
impl AzaleaWrite for ModelCustomization {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl io::Write) -> io::Result<()> {
let mut set = FixedBitSet::<7>::new();
if self.cape {
set.set(0);
diff --git a/azalea-protocol/src/common/movements.rs b/azalea-protocol/src/common/movements.rs
index cf51a57c..7ab7fc2f 100644
--- a/azalea-protocol/src/common/movements.rs
+++ b/azalea-protocol/src/common/movements.rs
@@ -48,7 +48,7 @@ impl AzaleaRead for RelativeMovements {
}
impl AzaleaWrite for RelativeMovements {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<32>::new();
let mut set_bit = |index: usize, value: bool| {
if value {
diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs
index 7ac8756e..fd092293 100644
--- a/azalea-protocol/src/lib.rs
+++ b/azalea-protocol/src/lib.rs
@@ -12,7 +12,11 @@
// this is necessary for thiserror backtraces
#![feature(error_generic_member_access)]
-use std::{fmt::Display, net::SocketAddr, str::FromStr};
+use std::{
+ fmt::{self, Display},
+ net::SocketAddr,
+ str::FromStr,
+};
pub mod common;
#[cfg(feature = "connecting")]
@@ -79,7 +83,7 @@ impl From<SocketAddr> for ServerAddress {
}
impl Display for ServerAddress {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.host, self.port)
}
}
diff --git a/azalea-protocol/src/packets/config/c_update_tags.rs b/azalea-protocol/src/packets/config/c_update_tags.rs
index 678a5ccf..750e3499 100644
--- a/azalea-protocol/src/packets/config/c_update_tags.rs
+++ b/azalea-protocol/src/packets/config/c_update_tags.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor};
use std::ops::Deref;
use std::{collections::HashMap, io::Write};
@@ -40,7 +40,7 @@ impl AzaleaRead for TagMap {
}
impl AzaleaWrite for TagMap {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(self.len() as u32).azalea_write_var(buf)?;
for (k, v) in &self.0 {
k.azalea_write(buf)?;
@@ -58,7 +58,7 @@ impl AzaleaRead for Tags {
}
impl AzaleaWrite for Tags {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.name.azalea_write(buf)?;
self.elements.azalea_write_var(buf)?;
Ok(())
diff --git a/azalea-protocol/src/packets/game/c_boss_event.rs b/azalea-protocol/src/packets/game/c_boss_event.rs
index 259a2781..18984985 100644
--- a/azalea-protocol/src/packets/game/c_boss_event.rs
+++ b/azalea-protocol/src/packets/game/c_boss_event.rs
@@ -1,3 +1,4 @@
+use std::io;
use std::io::Cursor;
use std::io::Write;
@@ -43,7 +44,7 @@ impl AzaleaRead for Operation {
}
impl AzaleaWrite for Operation {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
Operation::Add(add) => {
0u32.azalea_write_var(buf)?;
@@ -126,7 +127,7 @@ impl AzaleaRead for Properties {
}
impl AzaleaWrite for Properties {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<3>::new();
if self.darken_screen {
set.set(0);
diff --git a/azalea-protocol/src/packets/game/c_commands.rs b/azalea-protocol/src/packets/game/c_commands.rs
index c57f3d41..d2fa79a7 100644
--- a/azalea-protocol/src/packets/game/c_commands.rs
+++ b/azalea-protocol/src/packets/game/c_commands.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_core::{bitset::FixedBitSet, resource_location::ResourceLocation};
@@ -61,7 +61,7 @@ impl<T: AzaleaRead> AzaleaRead for BrigadierNumber<T> {
}
}
impl<T: AzaleaWrite> AzaleaWrite for BrigadierNumber<T> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut flags = FixedBitSet::<2>::new();
if self.min.is_some() {
flags.set(0);
@@ -166,7 +166,7 @@ impl AzaleaRead for EntityParser {
}
}
impl AzaleaWrite for EntityParser {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut flags = FixedBitSet::<2>::new();
if self.single {
flags.set(0);
@@ -242,7 +242,7 @@ impl AzaleaRead for BrigadierNodeStub {
}
impl AzaleaWrite for BrigadierNodeStub {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut flags = FixedBitSet::<4>::new();
if self.is_executable {
flags.set(2);
diff --git a/azalea-protocol/src/packets/game/c_damage_event.rs b/azalea-protocol/src/packets/game/c_damage_event.rs
index d4393685..b7fd15c1 100644
--- a/azalea-protocol/src/packets/game/c_damage_event.rs
+++ b/azalea-protocol/src/packets/game/c_damage_event.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar};
use azalea_core::position::Vec3;
@@ -27,7 +27,7 @@ impl AzaleaRead for OptionalEntityId {
}
}
impl AzaleaWrite for OptionalEntityId {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self.0 {
Some(id) => (id + 1).azalea_write_var(buf),
None => 0u32.azalea_write_var(buf),
diff --git a/azalea-protocol/src/packets/game/c_map_item_data.rs b/azalea-protocol/src/packets/game/c_map_item_data.rs
index 9a41ed85..f8c036e3 100644
--- a/azalea-protocol/src/packets/game/c_map_item_data.rs
+++ b/azalea-protocol/src/packets/game/c_map_item_data.rs
@@ -1,3 +1,5 @@
+use std::io::{self, Cursor, Write};
+
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite};
use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
@@ -27,7 +29,7 @@ pub struct MapDecoration {
pub struct OptionalMapPatch(pub Option<MapPatch>);
impl AzaleaRead for OptionalMapPatch {
- fn azalea_read(buf: &mut std::io::Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
+ fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
let pos = buf.position();
Ok(Self(if u8::azalea_read(buf)? == 0 {
None
@@ -39,7 +41,7 @@ impl AzaleaRead for OptionalMapPatch {
}
impl AzaleaWrite for OptionalMapPatch {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match &self.0 {
None => 0u8.azalea_write(buf),
Some(m) => m.azalea_write(buf),
diff --git a/azalea-protocol/src/packets/game/c_player_abilities.rs b/azalea-protocol/src/packets/game/c_player_abilities.rs
index c32a99fe..3f4e1024 100644
--- a/azalea-protocol/src/packets/game/c_player_abilities.rs
+++ b/azalea-protocol/src/packets/game/c_player_abilities.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, BufReadError};
use azalea_buf::{AzaleaRead, AzaleaWrite};
@@ -34,7 +34,7 @@ impl AzaleaRead for PlayerAbilitiesFlags {
}
impl AzaleaWrite for PlayerAbilitiesFlags {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<4>::new();
if self.invulnerable {
set.set(0);
diff --git a/azalea-protocol/src/packets/game/c_player_chat.rs b/azalea-protocol/src/packets/game/c_player_chat.rs
index 77dce487..d44e5f59 100644
--- a/azalea-protocol/src/packets/game/c_player_chat.rs
+++ b/azalea-protocol/src/packets/game/c_player_chat.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_chat::{
@@ -142,7 +142,7 @@ impl AzaleaRead for PackedMessageSignature {
}
}
impl AzaleaWrite for PackedMessageSignature {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
PackedMessageSignature::Signature(full_signature) => {
0u32.azalea_write_var(buf)?;
diff --git a/azalea-protocol/src/packets/game/c_player_info_update.rs b/azalea-protocol/src/packets/game/c_player_info_update.rs
index c8e32a33..0041b483 100644
--- a/azalea-protocol/src/packets/game/c_player_info_update.rs
+++ b/azalea-protocol/src/packets/game/c_player_info_update.rs
@@ -1,6 +1,6 @@
use std::{
collections::HashMap,
- io::{Cursor, Write},
+ io::{self, Cursor, Write},
};
use azalea_auth::game_profile::{GameProfile, ProfilePropertyValue};
@@ -119,7 +119,7 @@ impl AzaleaRead for ClientboundPlayerInfoUpdate {
}
impl AzaleaWrite for ClientboundPlayerInfoUpdate {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.actions.azalea_write(buf)?;
(self.entries.len() as u32).azalea_write_var(buf)?;
@@ -198,7 +198,7 @@ impl AzaleaRead for ActionEnumSet {
}
impl AzaleaWrite for ActionEnumSet {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<7>::new();
if self.add_player {
set.set(0);
diff --git a/azalea-protocol/src/packets/game/c_section_blocks_update.rs b/azalea-protocol/src/packets/game/c_section_blocks_update.rs
index 2a7a867e..b9d07db3 100644
--- a/azalea-protocol/src/packets/game/c_section_blocks_update.rs
+++ b/azalea-protocol/src/packets/game/c_section_blocks_update.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_block::BlockState;
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
@@ -34,7 +34,7 @@ impl AzaleaRead for BlockStateWithPosition {
}
impl AzaleaWrite for BlockStateWithPosition {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let data = ((self.state.id() as u64) << 12)
| ((u64::from(self.pos.x) << 8) | (u64::from(self.pos.z) << 4) | u64::from(self.pos.y));
u64::azalea_write_var(&data, buf)?;
diff --git a/azalea-protocol/src/packets/game/c_set_equipment.rs b/azalea-protocol/src/packets/game/c_set_equipment.rs
index ad691d66..c80e0072 100644
--- a/azalea-protocol/src/packets/game/c_set_equipment.rs
+++ b/azalea-protocol/src/packets/game/c_set_equipment.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, BufReadError};
use azalea_buf::{AzaleaRead, AzaleaWrite};
@@ -41,7 +41,7 @@ impl AzaleaRead for EquipmentSlots {
}
}
impl AzaleaWrite for EquipmentSlots {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
for i in 0..self.slots.len() {
let (equipment_slot, item) = &self.slots[i];
let mut equipment_byte = *equipment_slot as u8;
diff --git a/azalea-protocol/src/packets/game/c_set_objective.rs b/azalea-protocol/src/packets/game/c_set_objective.rs
index 7ddb3f71..0f5ffdc1 100644
--- a/azalea-protocol/src/packets/game/c_set_objective.rs
+++ b/azalea-protocol/src/packets/game/c_set_objective.rs
@@ -1,7 +1,7 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite};
-use azalea_chat::{numbers::NumberFormat, FormattedText};
+use azalea_chat::{FormattedText, numbers::NumberFormat};
use azalea_core::objectives::ObjectiveCriteria;
use azalea_protocol_macros::ClientboundGamePacket;
@@ -53,7 +53,7 @@ impl AzaleaRead for Method {
}
impl AzaleaWrite for Method {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
Method::Add {
display_name,
diff --git a/azalea-protocol/src/packets/game/c_stop_sound.rs b/azalea-protocol/src/packets/game/c_stop_sound.rs
index e3cd737e..da689882 100644
--- a/azalea-protocol/src/packets/game/c_stop_sound.rs
+++ b/azalea-protocol/src/packets/game/c_stop_sound.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
use azalea_core::{bitset::FixedBitSet, resource_location::ResourceLocation};
@@ -31,7 +31,7 @@ impl AzaleaRead for ClientboundStopSound {
}
impl AzaleaWrite for ClientboundStopSound {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<2>::new();
if self.source.is_some() {
set.set(0);
diff --git a/azalea-protocol/src/packets/game/c_update_advancements.rs b/azalea-protocol/src/packets/game/c_update_advancements.rs
index 1c645965..43542e56 100644
--- a/azalea-protocol/src/packets/game/c_update_advancements.rs
+++ b/azalea-protocol/src/packets/game/c_update_advancements.rs
@@ -1,5 +1,5 @@
use std::collections::HashMap;
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::AzBuf;
use azalea_chat::FormattedText;
@@ -38,7 +38,7 @@ pub struct DisplayInfo {
}
impl azalea_buf::AzaleaWrite for DisplayInfo {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.title.azalea_write(buf)?;
self.description.azalea_write(buf)?;
self.icon.azalea_write(buf)?;
diff --git a/azalea-protocol/src/packets/game/c_update_tags.rs b/azalea-protocol/src/packets/game/c_update_tags.rs
index 4b63ec8f..108f8772 100644
--- a/azalea-protocol/src/packets/game/c_update_tags.rs
+++ b/azalea-protocol/src/packets/game/c_update_tags.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor};
use std::ops::Deref;
use std::{collections::HashMap, io::Write};
@@ -40,7 +40,7 @@ impl AzaleaRead for TagMap {
}
impl AzaleaWrite for TagMap {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(self.len() as u32).azalea_write_var(buf)?;
for (k, v) in &self.0 {
k.azalea_write(buf)?;
@@ -58,7 +58,7 @@ impl AzaleaRead for Tags {
}
impl AzaleaWrite for Tags {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.name.azalea_write(buf)?;
self.elements.azalea_write_var(buf)?;
Ok(())
diff --git a/azalea-protocol/src/packets/game/s_interact.rs b/azalea-protocol/src/packets/game/s_interact.rs
index a3007749..762afe4e 100644
--- a/azalea-protocol/src/packets/game/s_interact.rs
+++ b/azalea-protocol/src/packets/game/s_interact.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar};
use azalea_core::position::Vec3;
@@ -29,7 +29,7 @@ pub enum ActionType {
}
impl AzaleaWrite for ActionType {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
ActionType::Interact { hand } => {
0u32.azalea_write_var(buf)?;
diff --git a/azalea-protocol/src/packets/game/s_player_abilities.rs b/azalea-protocol/src/packets/game/s_player_abilities.rs
index fdf2d8a4..da194228 100644
--- a/azalea-protocol/src/packets/game/s_player_abilities.rs
+++ b/azalea-protocol/src/packets/game/s_player_abilities.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaRead, AzaleaWrite};
use azalea_core::bitset::FixedBitSet;
@@ -21,7 +21,7 @@ impl AzaleaRead for ServerboundPlayerAbilities {
}
impl AzaleaWrite for ServerboundPlayerAbilities {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<2>::new();
if self.is_flying {
set.set(1);
diff --git a/azalea-protocol/src/packets/game/s_player_input.rs b/azalea-protocol/src/packets/game/s_player_input.rs
index 7032bcff..a12262b4 100644
--- a/azalea-protocol/src/packets/game/s_player_input.rs
+++ b/azalea-protocol/src/packets/game/s_player_input.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::BufReadError;
use azalea_buf::{AzaleaRead, AzaleaWrite};
@@ -32,7 +32,7 @@ impl AzaleaRead for ServerboundPlayerInput {
}
impl AzaleaWrite for ServerboundPlayerInput {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<7>::new();
if self.forward {
set.set(0);
diff --git a/azalea-protocol/src/packets/game/s_seen_advancements.rs b/azalea-protocol/src/packets/game/s_seen_advancements.rs
index f46411f0..d6fef907 100644
--- a/azalea-protocol/src/packets/game/s_seen_advancements.rs
+++ b/azalea-protocol/src/packets/game/s_seen_advancements.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite};
use azalea_core::resource_location::ResourceLocation;
@@ -31,7 +31,7 @@ impl AzaleaRead for ServerboundSeenAdvancements {
}
impl AzaleaWrite for ServerboundSeenAdvancements {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.action.azalea_write(buf)?;
if let Some(tab) = &self.tab {
tab.azalea_write(buf)?;
diff --git a/azalea-protocol/src/packets/game/s_set_command_block.rs b/azalea-protocol/src/packets/game/s_set_command_block.rs
index dacb79de..89cece2c 100644
--- a/azalea-protocol/src/packets/game/s_set_command_block.rs
+++ b/azalea-protocol/src/packets/game/s_set_command_block.rs
@@ -1,4 +1,4 @@
-use std::io::Cursor;
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, BufReadError};
use azalea_core::{bitset::FixedBitSet, position::BlockPos};
@@ -43,7 +43,7 @@ impl AzaleaRead for ServerboundSetCommandBlock {
}
impl AzaleaWrite for ServerboundSetCommandBlock {
- fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.pos.azalea_write(buf)?;
self.command.azalea_write(buf)?;
self.mode.azalea_write(buf)?;
diff --git a/azalea-protocol/src/packets/game/s_set_jigsaw_block.rs b/azalea-protocol/src/packets/game/s_set_jigsaw_block.rs
index 1d97d4c7..8c218ffd 100644
--- a/azalea-protocol/src/packets/game/s_set_jigsaw_block.rs
+++ b/azalea-protocol/src/packets/game/s_set_jigsaw_block.rs
@@ -1,3 +1,4 @@
+use std::io;
use std::io::Cursor;
use std::io::Write;
@@ -41,7 +42,7 @@ impl AzaleaRead for JointType {
}
impl AzaleaWrite for JointType {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
JointType::Rollable => "rollable".to_string().azalea_write(buf)?,
JointType::Aligned => "aligned".to_string().azalea_write(buf)?,
diff --git a/azalea-protocol/src/packets/game/s_set_structure_block.rs b/azalea-protocol/src/packets/game/s_set_structure_block.rs
index 360d34fc..8d518292 100644
--- a/azalea-protocol/src/packets/game/s_set_structure_block.rs
+++ b/azalea-protocol/src/packets/game/s_set_structure_block.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::AzBuf;
use azalea_buf::{AzaleaRead, AzaleaWrite};
@@ -83,7 +83,7 @@ impl AzaleaRead for Flags {
}
impl AzaleaWrite for Flags {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let mut set = FixedBitSet::<3>::new();
if self.ignore_entities {
set.set(0);
diff --git a/azalea-protocol/src/packets/game/s_use_item_on.rs b/azalea-protocol/src/packets/game/s_use_item_on.rs
index cfe4a5d3..11e32b2c 100644
--- a/azalea-protocol/src/packets/game/s_use_item_on.rs
+++ b/azalea-protocol/src/packets/game/s_use_item_on.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
use azalea_core::{
@@ -35,7 +35,7 @@ pub struct BlockHit {
}
impl AzaleaWrite for BlockHit {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.block_pos.azalea_write(buf)?;
self.direction.azalea_write(buf)?;
f32::azalea_write(
diff --git a/azalea-protocol/src/packets/login/c_login_disconnect.rs b/azalea-protocol/src/packets/login/c_login_disconnect.rs
index 580bfb2c..699801be 100644
--- a/azalea-protocol/src/packets/login/c_login_disconnect.rs
+++ b/azalea-protocol/src/packets/login/c_login_disconnect.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
use azalea_chat::FormattedText;
@@ -21,7 +21,7 @@ impl AzaleaRead for ClientboundLoginDisconnect {
Err(err) => {
return Err(BufReadError::Custom(format!(
"Failed to deserialize disconnect JSON {disconnect_string:?}: {err}"
- )))
+ )));
}
};
@@ -32,7 +32,7 @@ impl AzaleaRead for ClientboundLoginDisconnect {
}
impl AzaleaWrite for ClientboundLoginDisconnect {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let status_string = FormattedText::serialize(&self.reason, serde_json::value::Serializer)
.unwrap()
.to_string();
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs
index ade5c915..5e654491 100644
--- a/azalea-protocol/src/packets/mod.rs
+++ b/azalea-protocol/src/packets/mod.rs
@@ -5,7 +5,7 @@ pub mod handshake;
pub mod login;
pub mod status;
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
@@ -53,7 +53,7 @@ where
/// Read a packet by its id, `ConnectionProtocol`, and flow
fn read(id: u32, buf: &mut Cursor<&[u8]>) -> Result<Self, Box<ReadPacketError>>;
- fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>;
+ fn write(&self, buf: &mut impl Write) -> io::Result<()>;
}
pub trait Packet<Protocol> {
@@ -98,7 +98,7 @@ impl azalea_buf::AzaleaRead for ClientIntention {
}
impl AzaleaWrite for ClientIntention {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(*self as i32).azalea_write_var(buf)
}
}
diff --git a/azalea-protocol/src/packets/status/c_status_response.rs b/azalea-protocol/src/packets/status/c_status_response.rs
index b30c75be..5121f317 100644
--- a/azalea-protocol/src/packets/status/c_status_response.rs
+++ b/azalea-protocol/src/packets/status/c_status_response.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
use azalea_chat::FormattedText;
@@ -51,7 +51,7 @@ impl AzaleaRead for ClientboundStatusResponse {
}
impl AzaleaWrite for ClientboundStatusResponse {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
let status_string = ClientboundStatusResponse::serialize(self, Serializer)
.unwrap()
.to_string();
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index 038af319..422d7f7a 100644
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -1,8 +1,8 @@
//! Read packets from a stream.
use std::backtrace::Backtrace;
-use std::env;
use std::sync::LazyLock;
+use std::{env, io};
use std::{
fmt::Debug,
io::{Cursor, Read},
@@ -53,7 +53,7 @@ pub enum ReadPacketError {
IoError {
#[from]
#[backtrace]
- source: std::io::Error,
+ source: io::Error,
},
#[error("Connection closed")]
ConnectionClosed,
@@ -70,7 +70,7 @@ pub enum FrameSplitterError {
Io {
#[from]
#[backtrace]
- source: std::io::Error,
+ source: io::Error,
},
#[error("Packet is longer than {max} bytes (is {size})")]
BadLength { max: usize, size: usize },
@@ -171,7 +171,7 @@ pub enum DecompressionError {
Io {
#[from]
#[backtrace]
- source: std::io::Error,
+ source: io::Error,
},
#[error("Badly compressed packet - size of {size} is below server threshold of {threshold}")]
BelowCompressionThreshold { size: u32, threshold: u32 },
diff --git a/azalea-registry/src/lib.rs b/azalea-registry/src/lib.rs
index 11e44829..4f0623f6 100644
--- a/azalea-registry/src/lib.rs
+++ b/azalea-registry/src/lib.rs
@@ -42,7 +42,7 @@ impl<T: Registry> AzaleaRead for OptionalRegistry<T> {
}
}
impl<T: Registry> AzaleaWrite for OptionalRegistry<T> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match &self.0 {
None => 0u32.azalea_write_var(buf),
Some(value) => (value.to_u32() + 1).azalea_write_var(buf),
@@ -67,7 +67,7 @@ impl<D: Registry, C: AzaleaRead + AzaleaWrite> AzaleaRead for CustomRegistry<D,
}
}
impl<D: Registry, C: AzaleaRead + AzaleaWrite> AzaleaWrite for CustomRegistry<D, C> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
CustomRegistry::Direct(direct_registry) => {
// write the id + 1
@@ -115,7 +115,7 @@ impl<D: Registry, ResourceLocation: AzaleaRead + AzaleaWrite> AzaleaRead
impl<D: Registry, ResourceLocation: AzaleaRead + AzaleaWrite> AzaleaWrite
for HolderSet<D, ResourceLocation>
{
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
Self::Direct { contents } => {
(contents.len() as i32 + 1).azalea_write_var(buf)?;
@@ -167,7 +167,7 @@ impl<R: Registry, Direct: AzaleaRead + AzaleaWrite> AzaleaRead for Holder<R, Dir
}
}
impl<R: Registry, Direct: AzaleaRead + AzaleaWrite> AzaleaWrite for Holder<R, Direct> {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
Self::Reference(value) => (value.to_u32() + 1).azalea_write_var(buf),
Self::Direct(value) => {
diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs
index 9e97a7a7..b3ccbe3a 100644
--- a/azalea-world/src/chunk_storage.rs
+++ b/azalea-world/src/chunk_storage.rs
@@ -5,6 +5,7 @@ use std::{
io::{Cursor, Write},
sync::{Arc, Weak},
};
+use std::{fmt, io};
use azalea_block::block_state::{BlockState, BlockStateIntegerRepr};
use azalea_block::fluid_state::FluidState;
@@ -414,7 +415,7 @@ pub fn get_block_state_from_sections(
}
impl AzaleaWrite for Chunk {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
for section in &self.sections {
section.azalea_write(buf)?;
}
@@ -423,7 +424,7 @@ impl AzaleaWrite for Chunk {
}
impl Debug for PartialChunkStorage {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PartialChunkStorage")
.field("view_center", &self.view_center)
.field("chunk_radius", &self.chunk_radius)
@@ -466,7 +467,7 @@ impl AzaleaRead for Section {
}
impl AzaleaWrite for Section {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.block_count.azalea_write(buf)?;
self.states.azalea_write(buf)?;
self.biomes.azalea_write(buf)?;
diff --git a/azalea-world/src/heightmap.rs b/azalea-world/src/heightmap.rs
index 00ebad41..462d5b09 100644
--- a/azalea-world/src/heightmap.rs
+++ b/azalea-world/src/heightmap.rs
@@ -1,4 +1,7 @@
-use std::{fmt::Display, str::FromStr};
+use std::{
+ fmt::{self, Display},
+ str::FromStr,
+};
use azalea_block::BlockState;
use azalea_buf::AzBuf;
@@ -161,7 +164,7 @@ impl FromStr for HeightmapKind {
}
impl Display for HeightmapKind {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
HeightmapKind::WorldSurfaceWg => write!(f, "WORLD_SURFACE_WG"),
HeightmapKind::WorldSurface => write!(f, "WORLD_SURFACE"),
diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs
index 37d43fac..cef9bdee 100644
--- a/azalea-world/src/palette.rs
+++ b/azalea-world/src/palette.rs
@@ -1,4 +1,4 @@
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
use azalea_block::BlockState;
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
@@ -232,7 +232,7 @@ impl PalettedContainer {
}
impl AzaleaWrite for PalettedContainer {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.bits_per_entry.azalea_write(buf)?;
self.palette.azalea_write(buf)?;
self.storage.data.azalea_write(buf)?;
@@ -272,7 +272,7 @@ impl Palette {
}
impl AzaleaWrite for Palette {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
Palette::SingleValue(value) => {
value.azalea_write(buf)?;
diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs
index 4b2b2a19..9a734ab1 100644
--- a/azalea-world/src/world.rs
+++ b/azalea-world/src/world.rs
@@ -1,9 +1,9 @@
-use std::fmt::{self, Display, Formatter};
-use std::hash::{Hash, Hasher};
-use std::io::{self, Cursor};
use std::{
collections::{HashMap, HashSet},
fmt::Debug,
+ fmt::{self, Display},
+ hash::{Hash, Hasher},
+ io::{self, Cursor},
};
use azalea_block::BlockState;
@@ -84,7 +84,7 @@ impl AzaleaRead for MinecraftEntityId {
}
}
impl AzaleaWrite for MinecraftEntityId {
- fn azalea_write(&self, buf: &mut impl io::Write) -> Result<(), io::Error> {
+ fn azalea_write(&self, buf: &mut impl io::Write) -> io::Result<()> {
i32::azalea_write(&self.0, buf)
}
}
@@ -94,12 +94,12 @@ impl AzaleaReadVar for MinecraftEntityId {
}
}
impl AzaleaWriteVar for MinecraftEntityId {
- fn azalea_write_var(&self, buf: &mut impl io::Write) -> Result<(), io::Error> {
+ fn azalea_write_var(&self, buf: &mut impl io::Write) -> io::Result<()> {
i32::azalea_write_var(&self.0, buf)
}
}
impl Display for MinecraftEntityId {
- fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "eid({})", self.0)
}
}
@@ -176,7 +176,7 @@ impl Instance {
}
impl Debug for PartialInstance {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PartialInstance")
.field("chunks", &self.chunks)
.field("entity_infos", &self.entity_infos)
diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs
index 1e773b7d..80b0cb15 100644
--- a/azalea/examples/echo.rs
+++ b/azalea/examples/echo.rs
@@ -18,13 +18,14 @@ async fn main() {
pub struct State {}
async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> {
- if let Event::Chat(m) = event {
- if let (Some(sender), content) = m.split_sender_and_content() {
- if sender == bot.username() {
- return Ok(()); // ignore our own messages
- }
- bot.chat(&content);
- };
+ if let Event::Chat(m) = event
+ && let (Some(sender), content) = m.split_sender_and_content()
+ {
+ if sender == bot.username() {
+ // ignore our own messages
+ return Ok(());
+ }
+ bot.chat(&content);
}
Ok(())
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs
index 075348b2..b97ad71d 100644
--- a/azalea/examples/testbot/commands/debug.rs
+++ b/azalea/examples/testbot/commands/debug.rs
@@ -1,6 +1,6 @@
//! Commands for debugging and getting the current state of the bot.
-use std::{env, fs::File, io::Write, thread, time::Duration};
+use std::{env, fs::File, io::Write, process, thread, time::Duration};
use azalea::{
BlockPos,
@@ -288,7 +288,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
thread::spawn(move || {
thread::sleep(Duration::from_secs(1));
- std::process::exit(0);
+ process::exit(0);
});
1
diff --git a/azalea/src/container.rs b/azalea/src/container.rs
index 0d1cfb16..ebc033f3 100644
--- a/azalea/src/container.rs
+++ b/azalea/src/container.rs
@@ -1,5 +1,5 @@
+use std::fmt;
use std::fmt::Debug;
-use std::fmt::Formatter;
use azalea_client::packet::game::ReceiveGamePacketEvent;
use azalea_client::{
@@ -121,7 +121,7 @@ pub struct ContainerHandleRef {
client: Client,
}
impl Debug for ContainerHandleRef {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ContainerHandle")
.field("id", &self.id())
.finish()
@@ -192,7 +192,7 @@ impl Drop for ContainerHandle {
}
}
impl Debug for ContainerHandle {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ContainerHandle")
.field("id", &self.id())
.finish()
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs
index feddb57b..e33001e7 100644
--- a/azalea/src/pathfinder/astar.rs
+++ b/azalea/src/pathfinder/astar.rs
@@ -1,7 +1,7 @@
use std::{
cmp::{self},
collections::BinaryHeap,
- fmt::Debug,
+ fmt::{self, Debug},
hash::{BuildHasherDefault, Hash},
time::{Duration, Instant},
};
@@ -251,7 +251,7 @@ pub struct Movement<P: Hash + Copy, M> {
}
impl<P: Hash + Copy + Debug, M: Debug> Debug for Movement<P, M> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Movement")
.field("target", &self.target)
.field("data", &self.data)
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index afb1cc4d..58c3736c 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -1189,6 +1189,7 @@ mod tests {
use std::{
collections::HashSet,
sync::Arc,
+ thread,
time::{Duration, Instant},
};
@@ -1270,7 +1271,7 @@ mod tests {
&& start_time.elapsed() < Duration::from_millis(500)
{
simulation.tick();
- std::thread::yield_now();
+ thread::yield_now();
}
}
diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs
index 24dc8ac1..88bae957 100644
--- a/azalea/src/pathfinder/moves/mod.rs
+++ b/azalea/src/pathfinder/moves/mod.rs
@@ -1,7 +1,10 @@
pub mod basic;
pub mod parkour;
-use std::{fmt::Debug, sync::Arc};
+use std::{
+ fmt::{self, Debug},
+ sync::Arc,
+};
use azalea_block::BlockState;
use azalea_client::{
@@ -40,7 +43,7 @@ pub struct MoveData {
pub is_reached: &'static (dyn Fn(IsReachedCtx) -> bool + Send + Sync),
}
impl Debug for MoveData {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MoveData")
// .field("move_kind", &self.move_kind)
.finish()