From 1fb2be46d4f841456b3f08fddac8919c5eaccfcc Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Thu, 20 Feb 2025 18:42:20 +0100 Subject: [PATCH] Update to Rust edition 2024 --- Cargo.toml | 2 +- fuzz/Cargo.toml | 2 +- pumpkin-api-macros/src/lib.rs | 2 +- pumpkin-config/src/lib.rs | 11 ++++--- pumpkin-data/build/entity_type.rs | 2 +- pumpkin-data/build/item.rs | 2 +- pumpkin-inventory/src/crafting.rs | 4 +-- pumpkin-inventory/src/open_container.rs | 8 ++--- pumpkin-inventory/src/player.rs | 2 +- pumpkin-macros/src/lib.rs | 23 ++++++------- pumpkin-nbt/src/compound.rs | 2 +- pumpkin-nbt/src/deserializer.rs | 2 +- pumpkin-nbt/src/lib.rs | 2 +- pumpkin-nbt/src/serializer.rs | 6 ++-- pumpkin-protocol/src/bytebuf/mod.rs | 8 ++--- pumpkin-protocol/src/bytebuf/packet.rs | 6 ++-- pumpkin-protocol/src/bytebuf/serializer.rs | 2 +- .../src/client/config/known_packs.rs | 2 +- .../src/client/config/registry_data.rs | 2 +- .../src/client/config/store_cookie.rs | 2 +- .../src/client/config/update_tags.rs | 2 +- .../src/client/login/login_success.rs | 2 +- .../src/client/play/chunk_data.rs | 6 ++-- .../src/client/play/command_suggestions.rs | 2 +- pumpkin-protocol/src/client/play/commands.rs | 15 ++++++--- .../src/client/play/entity_sound_effect.rs | 2 +- .../client/play/initialize_world_border.rs | 2 +- pumpkin-protocol/src/client/play/login.rs | 2 +- .../src/client/play/player_chat_message.rs | 2 +- .../src/client/play/player_info_update.rs | 2 +- .../src/client/play/player_position.rs | 2 +- .../src/client/play/player_remove.rs | 2 +- pumpkin-protocol/src/client/play/respawn.rs | 2 +- .../src/client/play/set_container_content.rs | 2 +- .../src/client/play/set_container_slot.rs | 2 +- .../src/client/play/set_equipment.rs | 4 +-- .../src/client/play/sound_effect.rs | 2 +- .../src/client/play/store_cookie.rs | 2 +- .../src/client/play/teleport_entity.rs | 2 +- .../src/client/play/update_objectives.rs | 2 +- pumpkin-protocol/src/codec/bit_set.rs | 2 +- pumpkin-protocol/src/codec/identifier.rs | 2 +- pumpkin-protocol/src/codec/slot.rs | 2 +- pumpkin-protocol/src/codec/var_int.rs | 2 +- pumpkin-protocol/src/codec/var_long.rs | 2 +- pumpkin-protocol/src/lib.rs | 4 +-- pumpkin-protocol/src/packet_decoder.rs | 6 ++-- pumpkin-protocol/src/packet_encoder.rs | 6 ++-- .../src/server/config/cookie_response.rs | 2 +- .../src/server/config/plugin_message.rs | 2 +- pumpkin-protocol/src/server/handshake/mod.rs | 2 +- .../src/server/login/cookie_response.rs | 2 +- .../src/server/login/encryption_response.rs | 2 +- .../src/server/login/login_start.rs | 2 +- .../src/server/login/plugin_response.rs | 2 +- .../src/server/play/chat_message.rs | 2 +- .../src/server/play/click_container.rs | 4 +-- .../src/server/play/cookie_response.rs | 2 +- pumpkin-protocol/src/server/play/interact.rs | 2 +- .../src/server/play/player_command.rs | 2 +- .../src/server/play/update_sign.rs | 2 +- pumpkin-registry/src/lib.rs | 2 +- pumpkin-registry/src/recipe/read.rs | 4 +-- pumpkin-util/src/random/legacy_rand.rs | 4 +-- pumpkin-util/src/random/xoroshiro128.rs | 4 +-- pumpkin-util/src/text/mod.rs | 2 +- pumpkin-world/benches/chunk_noise_populate.rs | 4 +-- pumpkin-world/src/chunk/anvil.rs | 6 ++-- pumpkin-world/src/chunk/linear.rs | 4 +-- pumpkin-world/src/chunk/mod.rs | 4 +-- .../src/generation/aquifer_sampler.rs | 16 +++------- pumpkin-world/src/generation/chunk_noise.rs | 2 +- .../src/generation/generic_generator.rs | 4 +-- .../generation/implementation/superflat.rs | 2 +- .../src/generation/implementation/test.rs | 6 ++-- pumpkin-world/src/generation/mod.rs | 2 +- pumpkin-world/src/generation/noise/perlin.rs | 12 ++++--- pumpkin-world/src/generation/noise/simplex.rs | 6 ++-- .../noise_router/density_function/misc.rs | 2 +- .../noise_router/density_function/test.rs | 4 +-- .../noise_router/multi_noise_sampler.rs | 8 +++-- .../noise_router/proto_noise_router.rs | 6 ++-- pumpkin-world/src/generation/positions.rs | 2 +- pumpkin-world/src/generation/proto_chunk.rs | 6 ++-- pumpkin-world/src/generation/seed.rs | 2 +- pumpkin-world/src/level.rs | 14 ++++---- pumpkin-world/src/lib.rs | 2 +- pumpkin-world/src/world_info/anvil.rs | 4 +-- pumpkin/Cargo.toml | 4 +-- pumpkin/src/block/blocks/chest.rs | 2 +- pumpkin/src/block/blocks/lever.rs | 2 +- pumpkin/src/block/mod.rs | 2 +- pumpkin/src/block/properties/attachment.rs | 2 +- pumpkin/src/block/properties/axis.rs | 2 +- pumpkin/src/block/properties/cardinal.rs | 2 +- pumpkin/src/block/properties/face.rs | 2 +- pumpkin/src/block/properties/facing.rs | 2 +- pumpkin/src/block/properties/half.rs | 2 +- pumpkin/src/block/properties/layers.rs | 2 +- pumpkin/src/block/properties/mod.rs | 2 +- pumpkin/src/block/properties/signal_fire.rs | 2 +- pumpkin/src/block/properties/slab_type.rs | 2 +- pumpkin/src/block/properties/stair_shape.rs | 4 +-- pumpkin/src/block/properties/waterlog.rs | 2 +- pumpkin/src/block/pumpkin_block.rs | 2 +- pumpkin/src/block/registry.rs | 2 +- pumpkin/src/command/args/block.rs | 2 +- pumpkin/src/command/args/bool.rs | 2 +- pumpkin/src/command/args/bossbar_color.rs | 2 +- pumpkin/src/command/args/bossbar_style.rs | 2 +- pumpkin/src/command/args/bounded_num.rs | 2 +- pumpkin/src/command/args/command.rs | 2 +- pumpkin/src/command/args/damage_type.rs | 2 +- pumpkin/src/command/args/entities.rs | 2 +- pumpkin/src/command/args/entity.rs | 2 +- pumpkin/src/command/args/gamemode.rs | 2 +- pumpkin/src/command/args/item.rs | 2 +- pumpkin/src/command/args/message.rs | 2 +- pumpkin/src/command/args/mod.rs | 4 +-- pumpkin/src/command/args/particle.rs | 2 +- pumpkin/src/command/args/players.rs | 2 +- pumpkin/src/command/args/position_2d.rs | 2 +- pumpkin/src/command/args/position_3d.rs | 2 +- pumpkin/src/command/args/position_block.rs | 2 +- pumpkin/src/command/args/resource_location.rs | 2 +- pumpkin/src/command/args/rotation.rs | 2 +- pumpkin/src/command/args/simple.rs | 2 +- pumpkin/src/command/args/sound.rs | 2 +- pumpkin/src/command/args/sound_category.rs | 2 +- .../src/command/args/summonable_entities.rs | 2 +- pumpkin/src/command/args/textcomponent.rs | 2 +- pumpkin/src/command/args/time.rs | 2 +- pumpkin/src/command/commands/ban.rs | 10 +++--- pumpkin/src/command/commands/banip.rs | 10 +++--- pumpkin/src/command/commands/banlist.rs | 10 +++--- pumpkin/src/command/commands/bossbar.rs | 4 +-- pumpkin/src/command/commands/clear.rs | 4 +-- pumpkin/src/command/commands/damage.rs | 12 +++---- pumpkin/src/command/commands/deop.rs | 10 +++--- pumpkin/src/command/commands/experience.rs | 4 +-- pumpkin/src/command/commands/fill.rs | 2 +- pumpkin/src/command/commands/gamemode.rs | 6 ++-- pumpkin/src/command/commands/give.rs | 4 +-- pumpkin/src/command/commands/help.rs | 4 +-- pumpkin/src/command/commands/kick.rs | 6 ++-- pumpkin/src/command/commands/kill.rs | 4 +-- pumpkin/src/command/commands/list.rs | 2 +- pumpkin/src/command/commands/me.rs | 6 ++-- pumpkin/src/command/commands/msg.rs | 10 +++--- pumpkin/src/command/commands/op.rs | 12 +++---- pumpkin/src/command/commands/pardon.rs | 10 +++--- pumpkin/src/command/commands/pardonip.rs | 10 +++--- pumpkin/src/command/commands/particle.rs | 8 ++--- pumpkin/src/command/commands/playsound.rs | 14 ++++---- pumpkin/src/command/commands/plugin.rs | 10 +++--- pumpkin/src/command/commands/plugins.rs | 6 ++-- pumpkin/src/command/commands/pumpkin.rs | 6 ++-- pumpkin/src/command/commands/say.rs | 6 ++-- pumpkin/src/command/commands/seed.rs | 6 ++-- pumpkin/src/command/commands/setblock.rs | 2 +- pumpkin/src/command/commands/stop.rs | 2 +- pumpkin/src/command/commands/summon.rs | 8 ++--- pumpkin/src/command/commands/teleport.rs | 8 ++--- pumpkin/src/command/commands/time.rs | 6 ++-- pumpkin/src/command/commands/title.rs | 8 ++--- pumpkin/src/command/commands/transfer.rs | 4 +-- pumpkin/src/command/commands/weather.rs | 6 ++-- pumpkin/src/command/commands/worldborder.rs | 8 ++--- pumpkin/src/command/dispatcher.rs | 22 +++++++++---- pumpkin/src/command/tree/builder.rs | 2 +- pumpkin/src/command/tree/mod.rs | 2 +- pumpkin/src/data/banned_ip_data.rs | 2 +- pumpkin/src/data/banned_player_data.rs | 2 +- pumpkin/src/data/mod.rs | 2 +- pumpkin/src/entity/combat.rs | 8 ++--- pumpkin/src/entity/item.rs | 4 +-- pumpkin/src/entity/mob/mod.rs | 3 +- pumpkin/src/entity/mod.rs | 2 +- pumpkin/src/entity/player.rs | 10 +++--- pumpkin/src/entity/projectile/mod.rs | 2 +- pumpkin/src/lib.rs | 10 +++--- pumpkin/src/main.rs | 10 +++--- pumpkin/src/net/authentication.rs | 4 +-- pumpkin/src/net/container.rs | 6 ++-- pumpkin/src/net/lan_broadcast.rs | 4 ++- pumpkin/src/net/mod.rs | 12 +++---- pumpkin/src/net/packet/config.rs | 2 +- pumpkin/src/net/packet/handshake.rs | 2 +- pumpkin/src/net/packet/login.rs | 32 +++++++++++++------ pumpkin/src/net/packet/play.rs | 10 +++--- pumpkin/src/net/proxy/bungeecord.rs | 2 +- pumpkin/src/net/proxy/velocity.rs | 6 ++-- pumpkin/src/net/query.rs | 2 +- pumpkin/src/net/rcon/mod.rs | 2 +- .../plugin/api/events/block/block_break.rs | 2 +- .../src/plugin/api/events/block/block_burn.rs | 2 +- .../api/events/block/block_can_build.rs | 2 +- .../plugin/api/events/block/block_place.rs | 2 +- .../plugin/api/events/player/player_join.rs | 2 +- .../plugin/api/events/player/player_leave.rs | 2 +- .../src/plugin/api/events/world/chunk_load.rs | 2 +- .../src/plugin/api/events/world/chunk_save.rs | 2 +- .../src/plugin/api/events/world/chunk_send.rs | 2 +- pumpkin/src/server/connection_cache.rs | 8 ++--- pumpkin/src/server/key_store.rs | 2 +- pumpkin/src/server/mod.rs | 4 +-- pumpkin/src/world/mod.rs | 21 ++++++------ pumpkin/src/world/scoreboard.rs | 2 +- 208 files changed, 462 insertions(+), 439 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1aa60adf6..65710be7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ members = [ [workspace.package] version = "0.1.0" -edition = "2021" +edition = "2024" [profile.dev] diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 5379b3616..44befdd44 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -2,7 +2,7 @@ name = "pumpkin-fuzz" version = "0.0.0" publish = false -edition = "2021" +edition = "2024" [package.metadata] cargo-fuzz = true diff --git a/pumpkin-api-macros/src/lib.rs b/pumpkin-api-macros/src/lib.rs index dbbd4d4fb..cc7e33dc1 100644 --- a/pumpkin-api-macros/src/lib.rs +++ b/pumpkin-api-macros/src/lib.rs @@ -2,7 +2,7 @@ use proc_macro::TokenStream; use quote::quote; use std::sync::LazyLock; use std::sync::Mutex; -use syn::{parse_macro_input, parse_quote, ImplItem, ItemFn, ItemImpl, ItemStruct}; +use syn::{ImplItem, ItemFn, ItemImpl, ItemStruct, parse_macro_input, parse_quote}; static PLUGIN_METHODS: LazyLock>> = LazyLock::new(|| Mutex::new(Vec::new())); diff --git a/pumpkin-config/src/lib.rs b/pumpkin-config/src/lib.rs index 7dd87e161..65255e993 100644 --- a/pumpkin-config/src/lib.rs +++ b/pumpkin-config/src/lib.rs @@ -2,7 +2,7 @@ use chunk::ChunkConfig; use log::warn; use logging::LoggingConfig; use pumpkin_util::{Difficulty, GameMode, PermissionLvl}; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::DeserializeOwned}; use std::{ env, fs, @@ -184,14 +184,15 @@ impl LoadConfiguration for BasicConfiguration { } fn validate(&self) { + let min = unsafe { NonZeroU8::new_unchecked(2) }; + let max = unsafe { NonZeroU8::new_unchecked(32) }; + assert!( - self.view_distance - .ge(unsafe { &NonZeroU8::new_unchecked(2) }), + self.view_distance.ge(&min), "View distance must be at least 2" ); assert!( - self.view_distance - .le(unsafe { &NonZeroU8::new_unchecked(32) }), + self.view_distance.le(&max), "View distance must be less than 32" ); if self.online_mode { diff --git a/pumpkin-data/build/entity_type.rs b/pumpkin-data/build/entity_type.rs index 8ee8dc683..8a1b4800a 100644 --- a/pumpkin-data/build/entity_type.rs +++ b/pumpkin-data/build/entity_type.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use proc_macro2::TokenStream; -use quote::{format_ident, quote, ToTokens}; +use quote::{ToTokens, format_ident, quote}; use serde::Deserialize; use syn::LitInt; diff --git a/pumpkin-data/build/item.rs b/pumpkin-data/build/item.rs index 2d0197cab..95d1fe14b 100644 --- a/pumpkin-data/build/item.rs +++ b/pumpkin-data/build/item.rs @@ -1,6 +1,6 @@ use heck::ToShoutySnakeCase; use proc_macro2::{Span, TokenStream}; -use quote::{format_ident, quote, ToTokens}; +use quote::{ToTokens, format_ident, quote}; use syn::{Ident, LitBool, LitFloat, LitInt, LitStr}; include!("../src/tag.rs"); diff --git a/pumpkin-inventory/src/crafting.rs b/pumpkin-inventory/src/crafting.rs index 0ab0dda0e..b5fcd1195 100644 --- a/pumpkin-inventory/src/crafting.rs +++ b/pumpkin-inventory/src/crafting.rs @@ -1,8 +1,8 @@ use pumpkin_data::{ item::Item, - tag::{get_tag_values, RegistryEntryList, RegistryKey, TagType}, + tag::{RegistryEntryList, RegistryKey, TagType, get_tag_values}, }; -use pumpkin_registry::{flatten_3x3, RecipeResult, RECIPES}; +use pumpkin_registry::{RECIPES, RecipeResult, flatten_3x3}; use pumpkin_world::item::ItemStack; use rayon::prelude::*; diff --git a/pumpkin-inventory/src/open_container.rs b/pumpkin-inventory/src/open_container.rs index a64fb76d3..d1dd35892 100644 --- a/pumpkin-inventory/src/open_container.rs +++ b/pumpkin-inventory/src/open_container.rs @@ -1,5 +1,5 @@ -use crate::crafting::check_if_matches_crafting; use crate::Container; +use crate::crafting::check_if_matches_crafting; use pumpkin_data::screen::WindowType; use pumpkin_util::math::position::BlockPos; use pumpkin_world::block::registry::Block; @@ -34,11 +34,7 @@ impl OpenContainer { pub fn remove_player(&mut self, player_id: i32) { if let Some(index) = self.players.iter().enumerate().find_map(|(index, id)| { - if *id == player_id { - Some(index) - } else { - None - } + if *id == player_id { Some(index) } else { None } }) { self.players.remove(index); } diff --git a/pumpkin-inventory/src/player.rs b/pumpkin-inventory/src/player.rs index b6eb2fa31..47ac7aafc 100644 --- a/pumpkin-inventory/src/player.rs +++ b/pumpkin-inventory/src/player.rs @@ -1,6 +1,6 @@ use crate::container_click::MouseClick; use crate::crafting::check_if_matches_crafting; -use crate::{handle_item_change, Container, InventoryError, WindowType}; +use crate::{Container, InventoryError, WindowType, handle_item_change}; use pumpkin_data::item::Item; use pumpkin_world::item::ItemStack; use std::iter::Chain; diff --git a/pumpkin-macros/src/lib.rs b/pumpkin-macros/src/lib.rs index 57adb0b66..45607f7ad 100644 --- a/pumpkin-macros/src/lib.rs +++ b/pumpkin-macros/src/lib.rs @@ -3,8 +3,9 @@ use proc_macro::TokenStream; use pumpkin_data::item::Item; use quote::quote; use syn::{ + Block, Expr, Field, Fields, ItemStruct, Stmt, parse::{Nothing, Parser}, - parse_macro_input, Block, Expr, Field, Fields, ItemStruct, Stmt, + parse_macro_input, }; extern crate proc_macro; @@ -161,14 +162,14 @@ pub fn client_packet(input: TokenStream, item: TokenStream) -> TokenStream { let input: proc_macro2::TokenStream = input.into(); let item: proc_macro2::TokenStream = item.into(); - let gen = quote! { + let code = quote! { #item impl #impl_generics crate::bytebuf::packet::Packet for #name #ty_generics { const PACKET_ID: i32 = #input; } }; - gen.into() + code.into() } #[proc_macro_attribute] @@ -180,14 +181,14 @@ pub fn server_packet(input: TokenStream, item: TokenStream) -> TokenStream { let input: proc_macro2::TokenStream = input.into(); let item: proc_macro2::TokenStream = item.into(); - let gen = quote! { + let code = quote! { #item impl #impl_generics crate::bytebuf::packet::Packet for #name #ty_generics { const PACKET_ID: i32 = #input; } }; - gen.into() + code.into() } #[proc_macro_attribute] @@ -205,7 +206,7 @@ pub fn pumpkin_block(input: TokenStream, item: TokenStream) -> TokenStream { let item: proc_macro2::TokenStream = item.into(); - let gen = quote! { + let code = quote! { #item impl #impl_generics crate::block::pumpkin_block::BlockMetadata for #name #ty_generics { const NAMESPACE: &'static str = #namespace; @@ -213,7 +214,7 @@ pub fn pumpkin_block(input: TokenStream, item: TokenStream) -> TokenStream { } }; - gen.into() + code.into() } #[proc_macro_attribute] @@ -229,14 +230,14 @@ pub fn pumpkin_item(input: TokenStream, item: TokenStream) -> TokenStream { let item: proc_macro2::TokenStream = item.into(); - let gen = quote! { + let code = quote! { #item impl #impl_generics crate::item::pumpkin_item::ItemMetadata for #name #ty_generics { const ID: u16 = #id; } }; - gen.into() + code.into() } #[proc_macro_attribute] @@ -351,7 +352,7 @@ pub fn block_property(input: TokenStream, item: TokenStream) -> TokenStream { } }; - let gen = quote! { + let code = quote! { #item impl #impl_generics crate::block::properties::BlockPropertyMetadata for #name #ty_generics { fn name(&self) -> &'static str { @@ -372,7 +373,7 @@ pub fn block_property(input: TokenStream, item: TokenStream) -> TokenStream { #extra }; - gen.into() + code.into() } mod block_state; diff --git a/pumpkin-nbt/src/compound.rs b/pumpkin-nbt/src/compound.rs index 0d0cbe4d4..ef6cd40ad 100644 --- a/pumpkin-nbt/src/compound.rs +++ b/pumpkin-nbt/src/compound.rs @@ -1,7 +1,7 @@ use crate::deserializer::ReadAdaptor; use crate::serializer::WriteAdaptor; use crate::tag::NbtTag; -use crate::{get_nbt_string, Error, Nbt, END_ID}; +use crate::{END_ID, Error, Nbt, get_nbt_string}; use std::io::{ErrorKind, Read, Write}; use std::vec::IntoIter; diff --git a/pumpkin-nbt/src/deserializer.rs b/pumpkin-nbt/src/deserializer.rs index 6331755cc..3d235762d 100644 --- a/pumpkin-nbt/src/deserializer.rs +++ b/pumpkin-nbt/src/deserializer.rs @@ -1,7 +1,7 @@ use crate::*; use io::Read; use serde::de::{self, DeserializeSeed, IntoDeserializer, MapAccess, SeqAccess, Visitor}; -use serde::{forward_to_deserialize_any, Deserialize}; +use serde::{Deserialize, forward_to_deserialize_any}; pub type Result = std::result::Result; diff --git a/pumpkin-nbt/src/lib.rs b/pumpkin-nbt/src/lib.rs index bd6edbe57..1d935282a 100644 --- a/pumpkin-nbt/src/lib.rs +++ b/pumpkin-nbt/src/lib.rs @@ -210,13 +210,13 @@ impl_array!(nbt_byte_array, NBT_BYTE_ARRAY_TAG); #[cfg(test)] mod test { + use crate::Error; use crate::deserializer::from_bytes; use crate::nbt_byte_array; use crate::nbt_int_array; use crate::nbt_long_array; use crate::serializer::to_bytes; use crate::serializer::to_bytes_named; - use crate::Error; use crate::{deserializer::from_bytes_unnamed, serializer::to_bytes_unnamed}; use serde::{Deserialize, Serialize}; diff --git a/pumpkin-nbt/src/serializer.rs b/pumpkin-nbt/src/serializer.rs index fdc6f9c20..65252799c 100644 --- a/pumpkin-nbt/src/serializer.rs +++ b/pumpkin-nbt/src/serializer.rs @@ -1,10 +1,10 @@ use serde::ser::Impossible; -use serde::{ser, Serialize}; +use serde::{Serialize, ser}; use std::io::Write; use crate::tag::NbtTag; use crate::{ - Error, BYTE_ARRAY_ID, BYTE_ID, COMPOUND_ID, DOUBLE_ID, END_ID, FLOAT_ID, INT_ARRAY_ID, INT_ID, + BYTE_ARRAY_ID, BYTE_ID, COMPOUND_ID, DOUBLE_ID, END_ID, Error, FLOAT_ID, INT_ARRAY_ID, INT_ID, LIST_ID, LONG_ARRAY_ID, LONG_ID, NBT_ARRAY_TAG, NBT_BYTE_ARRAY_TAG, NBT_INT_ARRAY_TAG, NBT_LONG_ARRAY_TAG, SHORT_ID, STRING_ID, }; @@ -393,7 +393,7 @@ impl ser::Serializer for &mut Serializer { _ => { return Err(Error::SerdeError( "Array supports only byte, int, long".to_string(), - )) + )); } }; diff --git a/pumpkin-protocol/src/bytebuf/mod.rs b/pumpkin-protocol/src/bytebuf/mod.rs index 54836a706..585a57235 100644 --- a/pumpkin-protocol/src/bytebuf/mod.rs +++ b/pumpkin-protocol/src/bytebuf/mod.rs @@ -1,11 +1,11 @@ use core::str; use crate::{ + FixedBitSet, codec::{ - bit_set::BitSet, identifier::Identifier, var_int::VarInt, var_long::VarLong, Codec, - DecodeError, + Codec, DecodeError, bit_set::BitSet, identifier::Identifier, var_int::VarInt, + var_long::VarLong, }, - FixedBitSet, }; use bytes::{Buf, BufMut}; @@ -279,8 +279,8 @@ mod test { use serde::{Deserialize, Serialize}; use crate::{ - bytebuf::{deserializer, serializer}, VarInt, + bytebuf::{deserializer, serializer}, }; #[test] diff --git a/pumpkin-protocol/src/bytebuf/packet.rs b/pumpkin-protocol/src/bytebuf/packet.rs index 6534033eb..fef08c480 100644 --- a/pumpkin-protocol/src/bytebuf/packet.rs +++ b/pumpkin-protocol/src/bytebuf/packet.rs @@ -1,9 +1,9 @@ use bytes::{Buf, BufMut}; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; -use crate::{codec::var_int::VarIntType, ClientPacket, ServerPacket}; +use crate::{ClientPacket, ServerPacket, codec::var_int::VarIntType}; -use super::{deserializer, serializer, ReadingError}; +use super::{ReadingError, deserializer, serializer}; pub trait Packet { const PACKET_ID: VarIntType; diff --git a/pumpkin-protocol/src/bytebuf/serializer.rs b/pumpkin-protocol/src/bytebuf/serializer.rs index 3d3afb55a..c0ae298a5 100644 --- a/pumpkin-protocol/src/bytebuf/serializer.rs +++ b/pumpkin-protocol/src/bytebuf/serializer.rs @@ -2,8 +2,8 @@ use std::fmt::Display; use bytes::BufMut; use serde::{ - ser::{self}, Serialize, + ser::{self}, }; use thiserror::Error; diff --git a/pumpkin-protocol/src/client/config/known_packs.rs b/pumpkin-protocol/src/client/config/known_packs.rs index 344750255..931d61e87 100644 --- a/pumpkin-protocol/src/client/config/known_packs.rs +++ b/pumpkin-protocol/src/client/config/known_packs.rs @@ -2,7 +2,7 @@ use bytes::BufMut; use pumpkin_data::packet::clientbound::CONFIG_SELECT_KNOWN_PACKS; use pumpkin_macros::client_packet; -use crate::{bytebuf::ByteBufMut, ClientPacket, KnownPack}; +use crate::{ClientPacket, KnownPack, bytebuf::ByteBufMut}; #[client_packet(CONFIG_SELECT_KNOWN_PACKS)] pub struct CKnownPacks<'a> { diff --git a/pumpkin-protocol/src/client/config/registry_data.rs b/pumpkin-protocol/src/client/config/registry_data.rs index 0733097bd..3181b4dce 100644 --- a/pumpkin-protocol/src/client/config/registry_data.rs +++ b/pumpkin-protocol/src/client/config/registry_data.rs @@ -3,7 +3,7 @@ use pumpkin_data::packet::clientbound::CONFIG_REGISTRY_DATA; use pumpkin_macros::client_packet; use serde::Serialize; -use crate::{bytebuf::ByteBufMut, codec::identifier::Identifier, ClientPacket}; +use crate::{ClientPacket, bytebuf::ByteBufMut, codec::identifier::Identifier}; #[client_packet(CONFIG_REGISTRY_DATA)] pub struct CRegistryData<'a> { diff --git a/pumpkin-protocol/src/client/config/store_cookie.rs b/pumpkin-protocol/src/client/config/store_cookie.rs index e6b283316..860549006 100644 --- a/pumpkin-protocol/src/client/config/store_cookie.rs +++ b/pumpkin-protocol/src/client/config/store_cookie.rs @@ -1,4 +1,4 @@ -use crate::{codec::identifier::Identifier, VarInt}; +use crate::{VarInt, codec::identifier::Identifier}; use pumpkin_data::packet::clientbound::CONFIG_STORE_COOKIE; use pumpkin_macros::client_packet; diff --git a/pumpkin-protocol/src/client/config/update_tags.rs b/pumpkin-protocol/src/client/config/update_tags.rs index d2c17956d..5bee3dcf6 100644 --- a/pumpkin-protocol/src/client/config/update_tags.rs +++ b/pumpkin-protocol/src/client/config/update_tags.rs @@ -8,9 +8,9 @@ use pumpkin_macros::client_packet; use pumpkin_world::block::registry; use crate::{ + ClientPacket, bytebuf::ByteBufMut, codec::{identifier::Identifier, var_int::VarInt}, - ClientPacket, }; #[client_packet(CONFIG_UPDATE_TAGS)] diff --git a/pumpkin-protocol/src/client/login/login_success.rs b/pumpkin-protocol/src/client/login/login_success.rs index a581128c4..600e7abab 100644 --- a/pumpkin-protocol/src/client/login/login_success.rs +++ b/pumpkin-protocol/src/client/login/login_success.rs @@ -2,7 +2,7 @@ use bytes::BufMut; use pumpkin_data::packet::clientbound::LOGIN_LOGIN_FINISHED; use pumpkin_macros::client_packet; -use crate::{bytebuf::ByteBufMut, ClientPacket, Property}; +use crate::{ClientPacket, Property, bytebuf::ByteBufMut}; #[client_packet(LOGIN_LOGIN_FINISHED)] pub struct CLoginSuccess<'a> { diff --git a/pumpkin-protocol/src/client/play/chunk_data.rs b/pumpkin-protocol/src/client/play/chunk_data.rs index dfe4af28e..053d6c3b6 100644 --- a/pumpkin-protocol/src/client/play/chunk_data.rs +++ b/pumpkin-protocol/src/client/play/chunk_data.rs @@ -1,11 +1,11 @@ -use crate::{bytebuf::ByteBufMut, codec::bit_set::BitSet, ClientPacket, VarInt}; +use crate::{ClientPacket, VarInt, bytebuf::ByteBufMut, codec::bit_set::BitSet}; use bytes::{BufMut, BytesMut}; use pumpkin_data::packet::clientbound::PLAY_LEVEL_CHUNK_WITH_LIGHT; use pumpkin_macros::client_packet; use pumpkin_world::{ - chunk::{ChunkData, SUBCHUNKS_COUNT}, DIRECT_PALETTE_BITS, + chunk::{ChunkData, SUBCHUNKS_COUNT}, }; #[client_packet(PLAY_LEVEL_CHUNK_WITH_LIGHT)] @@ -73,7 +73,7 @@ impl ClientPacket for CChunkData<'_> { .iter() .position(|b| b == block) .expect("Its just got added, ofc it should be there"); - out_long = out_long << block_size | (index as i64); + out_long = (out_long << block_size) | (index as i64); } data_buf.put_i64(out_long); } diff --git a/pumpkin-protocol/src/client/play/command_suggestions.rs b/pumpkin-protocol/src/client/play/command_suggestions.rs index f9a19cb82..59fe097d6 100644 --- a/pumpkin-protocol/src/client/play/command_suggestions.rs +++ b/pumpkin-protocol/src/client/play/command_suggestions.rs @@ -3,7 +3,7 @@ use pumpkin_data::packet::clientbound::PLAY_COMMAND_SUGGESTIONS; use pumpkin_macros::client_packet; use pumpkin_util::text::TextComponent; -use crate::{bytebuf::ByteBufMut, ClientPacket, VarInt}; +use crate::{ClientPacket, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_COMMAND_SUGGESTIONS)] pub struct CCommandSuggestions { diff --git a/pumpkin-protocol/src/client/play/commands.rs b/pumpkin-protocol/src/client/play/commands.rs index 6f743996d..09cf7628d 100644 --- a/pumpkin-protocol/src/client/play/commands.rs +++ b/pumpkin-protocol/src/client/play/commands.rs @@ -2,7 +2,7 @@ use bytes::BufMut; use pumpkin_data::packet::clientbound::PLAY_COMMANDS; use pumpkin_macros::client_packet; -use crate::{bytebuf::ByteBufMut, ClientPacket, VarInt}; +use crate::{ClientPacket, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_COMMANDS)] pub struct CCommands<'a> { @@ -114,12 +114,19 @@ impl ProtoNode<'_> { if flags & Self::FLAG_HAS_SUGGESTION_TYPE != 0 { match &self.node_type { - ProtoNodeType::Argument { name: _, is_executable: _, parser: _, override_suggestion_type } => { + ProtoNodeType::Argument { + name: _, + is_executable: _, + parser: _, + override_suggestion_type, + } => { // suggestion type let suggestion_type = &override_suggestion_type.expect("ProtoNode::FLAG_HAS_SUGGESTION_TYPE should only be set if override_suggestion_type is not None."); bytebuf.put_string(suggestion_type.identifier()); - }, - _ => unimplemented!("ProtoNode::FLAG_HAS_SUGGESTION_TYPE is only implemented for ProtoNodeType::Argument"), + } + _ => unimplemented!( + "ProtoNode::FLAG_HAS_SUGGESTION_TYPE is only implemented for ProtoNodeType::Argument" + ), } } } diff --git a/pumpkin-protocol/src/client/play/entity_sound_effect.rs b/pumpkin-protocol/src/client/play/entity_sound_effect.rs index 8be086015..86bc48cf0 100644 --- a/pumpkin-protocol/src/client/play/entity_sound_effect.rs +++ b/pumpkin-protocol/src/client/play/entity_sound_effect.rs @@ -2,7 +2,7 @@ use bytes::BufMut; use pumpkin_data::{packet::clientbound::PLAY_SOUND_ENTITY, sound::SoundCategory}; use pumpkin_macros::client_packet; -use crate::{bytebuf::ByteBufMut, ClientPacket, IDOrSoundEvent, SoundEvent, VarInt}; +use crate::{ClientPacket, IDOrSoundEvent, SoundEvent, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_SOUND_ENTITY)] pub struct CEntitySoundEffect { diff --git a/pumpkin-protocol/src/client/play/initialize_world_border.rs b/pumpkin-protocol/src/client/play/initialize_world_border.rs index 01eb9d568..0a17ea36c 100644 --- a/pumpkin-protocol/src/client/play/initialize_world_border.rs +++ b/pumpkin-protocol/src/client/play/initialize_world_border.rs @@ -2,7 +2,7 @@ use pumpkin_data::packet::clientbound::PLAY_INITIALIZE_BORDER; use pumpkin_macros::client_packet; use serde::Serialize; -use crate::{codec::var_long::VarLong, VarInt}; +use crate::{VarInt, codec::var_long::VarLong}; #[derive(Serialize)] #[client_packet(PLAY_INITIALIZE_BORDER)] diff --git a/pumpkin-protocol/src/client/play/login.rs b/pumpkin-protocol/src/client/play/login.rs index f32a06b8a..e8db05b5b 100644 --- a/pumpkin-protocol/src/client/play/login.rs +++ b/pumpkin-protocol/src/client/play/login.rs @@ -4,7 +4,7 @@ use pumpkin_util::math::position::BlockPos; use pumpkin_macros::client_packet; use serde::Serialize; -use crate::{codec::identifier::Identifier, VarInt}; +use crate::{VarInt, codec::identifier::Identifier}; #[derive(Serialize)] #[client_packet(PLAY_LOGIN)] diff --git a/pumpkin-protocol/src/client/play/player_chat_message.rs b/pumpkin-protocol/src/client/play/player_chat_message.rs index 76573f752..9387e4c56 100644 --- a/pumpkin-protocol/src/client/play/player_chat_message.rs +++ b/pumpkin-protocol/src/client/play/player_chat_message.rs @@ -4,7 +4,7 @@ use pumpkin_util::text::TextComponent; use pumpkin_macros::client_packet; use serde::Serialize; -use crate::{codec::bit_set::BitSet, VarInt}; +use crate::{VarInt, codec::bit_set::BitSet}; #[derive(Serialize)] #[client_packet(PLAY_PLAYER_CHAT)] diff --git a/pumpkin-protocol/src/client/play/player_info_update.rs b/pumpkin-protocol/src/client/play/player_info_update.rs index 502485fa1..0d0bc5183 100644 --- a/pumpkin-protocol/src/client/play/player_info_update.rs +++ b/pumpkin-protocol/src/client/play/player_info_update.rs @@ -2,7 +2,7 @@ use bytes::BufMut; use pumpkin_data::packet::clientbound::PLAY_PLAYER_INFO_UPDATE; use pumpkin_macros::client_packet; -use crate::{bytebuf::ByteBufMut, ClientPacket, Property}; +use crate::{ClientPacket, Property, bytebuf::ByteBufMut}; use super::PlayerAction; diff --git a/pumpkin-protocol/src/client/play/player_position.rs b/pumpkin-protocol/src/client/play/player_position.rs index 8aae24c6e..af89ecfeb 100644 --- a/pumpkin-protocol/src/client/play/player_position.rs +++ b/pumpkin-protocol/src/client/play/player_position.rs @@ -3,7 +3,7 @@ use pumpkin_data::packet::clientbound::PLAY_PLAYER_POSITION; use pumpkin_macros::client_packet; use pumpkin_util::math::vector3::Vector3; -use crate::{bytebuf::ByteBufMut, ClientPacket, PositionFlag, VarInt}; +use crate::{ClientPacket, PositionFlag, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_PLAYER_POSITION)] pub struct CPlayerPosition<'a> { diff --git a/pumpkin-protocol/src/client/play/player_remove.rs b/pumpkin-protocol/src/client/play/player_remove.rs index cfb57d369..22aa52afc 100644 --- a/pumpkin-protocol/src/client/play/player_remove.rs +++ b/pumpkin-protocol/src/client/play/player_remove.rs @@ -1,6 +1,6 @@ use pumpkin_data::packet::clientbound::PLAY_PLAYER_INFO_REMOVE; use pumpkin_macros::client_packet; -use serde::{ser::SerializeSeq, Serialize}; +use serde::{Serialize, ser::SerializeSeq}; use crate::VarInt; diff --git a/pumpkin-protocol/src/client/play/respawn.rs b/pumpkin-protocol/src/client/play/respawn.rs index 66cf233e9..61bfa9ce5 100644 --- a/pumpkin-protocol/src/client/play/respawn.rs +++ b/pumpkin-protocol/src/client/play/respawn.rs @@ -3,7 +3,7 @@ use pumpkin_macros::client_packet; use pumpkin_util::math::position::BlockPos; use serde::Serialize; -use crate::{codec::identifier::Identifier, VarInt}; +use crate::{VarInt, codec::identifier::Identifier}; #[derive(Serialize)] #[client_packet(PLAY_RESPAWN)] diff --git a/pumpkin-protocol/src/client/play/set_container_content.rs b/pumpkin-protocol/src/client/play/set_container_content.rs index da715f576..9aab6ded1 100644 --- a/pumpkin-protocol/src/client/play/set_container_content.rs +++ b/pumpkin-protocol/src/client/play/set_container_content.rs @@ -1,5 +1,5 @@ -use crate::codec::slot::Slot; use crate::VarInt; +use crate::codec::slot::Slot; use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_CONTENT; use pumpkin_macros::client_packet; diff --git a/pumpkin-protocol/src/client/play/set_container_slot.rs b/pumpkin-protocol/src/client/play/set_container_slot.rs index ada4544bc..d8a5ff0b0 100644 --- a/pumpkin-protocol/src/client/play/set_container_slot.rs +++ b/pumpkin-protocol/src/client/play/set_container_slot.rs @@ -1,5 +1,5 @@ -use crate::codec::slot::Slot; use crate::VarInt; +use crate::codec::slot::Slot; use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_SLOT; use pumpkin_macros::client_packet; diff --git a/pumpkin-protocol/src/client/play/set_equipment.rs b/pumpkin-protocol/src/client/play/set_equipment.rs index e13e00d4c..5a226dc90 100644 --- a/pumpkin-protocol/src/client/play/set_equipment.rs +++ b/pumpkin-protocol/src/client/play/set_equipment.rs @@ -1,12 +1,12 @@ -use crate::bytebuf::{serializer::Serializer, ByteBufMut}; +use crate::bytebuf::{ByteBufMut, serializer::Serializer}; use bytes::BytesMut; use pumpkin_data::packet::clientbound::PLAY_SET_EQUIPMENT; use pumpkin_macros::client_packet; use serde::Serialize; use crate::{ - codec::{slot::Slot, var_int::VarInt}, ClientPacket, + codec::{slot::Slot, var_int::VarInt}, }; #[client_packet(PLAY_SET_EQUIPMENT)] diff --git a/pumpkin-protocol/src/client/play/sound_effect.rs b/pumpkin-protocol/src/client/play/sound_effect.rs index 35bb02418..80f2841fd 100644 --- a/pumpkin-protocol/src/client/play/sound_effect.rs +++ b/pumpkin-protocol/src/client/play/sound_effect.rs @@ -3,7 +3,7 @@ use pumpkin_data::{packet::clientbound::PLAY_SOUND, sound::SoundCategory}; use pumpkin_macros::client_packet; use pumpkin_util::math::vector3::Vector3; -use crate::{bytebuf::ByteBufMut, ClientPacket, IDOrSoundEvent, SoundEvent, VarInt}; +use crate::{ClientPacket, IDOrSoundEvent, SoundEvent, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_SOUND)] pub struct CSoundEffect { diff --git a/pumpkin-protocol/src/client/play/store_cookie.rs b/pumpkin-protocol/src/client/play/store_cookie.rs index d20e7d91d..e8a52317b 100644 --- a/pumpkin-protocol/src/client/play/store_cookie.rs +++ b/pumpkin-protocol/src/client/play/store_cookie.rs @@ -1,4 +1,4 @@ -use crate::{codec::identifier::Identifier, VarInt}; +use crate::{VarInt, codec::identifier::Identifier}; use pumpkin_data::packet::clientbound::PLAY_STORE_COOKIE; use pumpkin_macros::client_packet; use serde::Serialize; diff --git a/pumpkin-protocol/src/client/play/teleport_entity.rs b/pumpkin-protocol/src/client/play/teleport_entity.rs index 789852406..85b7fa969 100644 --- a/pumpkin-protocol/src/client/play/teleport_entity.rs +++ b/pumpkin-protocol/src/client/play/teleport_entity.rs @@ -3,7 +3,7 @@ use pumpkin_data::packet::clientbound::PLAY_TELEPORT_ENTITY; use pumpkin_macros::client_packet; use pumpkin_util::math::vector3::Vector3; -use crate::{bytebuf::ByteBufMut, ClientPacket, PositionFlag, VarInt}; +use crate::{ClientPacket, PositionFlag, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_TELEPORT_ENTITY)] pub struct CTeleportEntity<'a> { diff --git a/pumpkin-protocol/src/client/play/update_objectives.rs b/pumpkin-protocol/src/client/play/update_objectives.rs index b98fdff7b..b6159d4e3 100644 --- a/pumpkin-protocol/src/client/play/update_objectives.rs +++ b/pumpkin-protocol/src/client/play/update_objectives.rs @@ -3,7 +3,7 @@ use pumpkin_data::packet::clientbound::PLAY_SET_OBJECTIVE; use pumpkin_macros::client_packet; use pumpkin_util::text::TextComponent; -use crate::{bytebuf::ByteBufMut, ClientPacket, NumberFormat, VarInt}; +use crate::{ClientPacket, NumberFormat, VarInt, bytebuf::ByteBufMut}; #[client_packet(PLAY_SET_OBJECTIVE)] pub struct CUpdateObjectives<'a> { diff --git a/pumpkin-protocol/src/codec/bit_set.rs b/pumpkin-protocol/src/codec/bit_set.rs index 27aa329d3..3b7fe9341 100644 --- a/pumpkin-protocol/src/codec/bit_set.rs +++ b/pumpkin-protocol/src/codec/bit_set.rs @@ -6,7 +6,7 @@ use serde::{Serialize, Serializer}; use crate::bytebuf::ByteBuf; use crate::bytebuf::ByteBufMut; -use super::{var_int::VarInt, Codec, DecodeError}; +use super::{Codec, DecodeError, var_int::VarInt}; pub struct BitSet(pub VarInt, pub Vec); diff --git a/pumpkin-protocol/src/codec/identifier.rs b/pumpkin-protocol/src/codec/identifier.rs index 0c8fb4b58..896513f5a 100644 --- a/pumpkin-protocol/src/codec/identifier.rs +++ b/pumpkin-protocol/src/codec/identifier.rs @@ -1,7 +1,7 @@ use std::num::NonZeroUsize; use bytes::{Buf, BufMut}; -use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor}; use crate::bytebuf::{ByteBuf, ByteBufMut}; diff --git a/pumpkin-protocol/src/codec/slot.rs b/pumpkin-protocol/src/codec/slot.rs index e3a754937..864626b1f 100644 --- a/pumpkin-protocol/src/codec/slot.rs +++ b/pumpkin-protocol/src/codec/slot.rs @@ -3,8 +3,8 @@ use pumpkin_data::item::Item; use pumpkin_world::item::ItemStack; use serde::ser::SerializeSeq; use serde::{ - de::{self, SeqAccess}, Deserialize, Serialize, Serializer, + de::{self, SeqAccess}, }; #[derive(Debug, Clone)] diff --git a/pumpkin-protocol/src/codec/var_int.rs b/pumpkin-protocol/src/codec/var_int.rs index 4f502687f..0c668652d 100644 --- a/pumpkin-protocol/src/codec/var_int.rs +++ b/pumpkin-protocol/src/codec/var_int.rs @@ -3,8 +3,8 @@ use std::{num::NonZeroUsize, ops::Deref}; use super::{Codec, DecodeError}; use bytes::{Buf, BufMut}; use serde::{ - de::{SeqAccess, Visitor}, Deserialize, Deserializer, Serialize, Serializer, + de::{SeqAccess, Visitor}, }; pub type VarIntType = i32; diff --git a/pumpkin-protocol/src/codec/var_long.rs b/pumpkin-protocol/src/codec/var_long.rs index ceb2c1c99..c58c89fea 100644 --- a/pumpkin-protocol/src/codec/var_long.rs +++ b/pumpkin-protocol/src/codec/var_long.rs @@ -3,8 +3,8 @@ use std::{num::NonZeroUsize, ops::Deref}; use super::{Codec, DecodeError}; use bytes::{Buf, BufMut}; use serde::{ - de::{self, SeqAccess, Visitor}, Deserialize, Deserializer, Serialize, Serializer, + de::{self, SeqAccess, Visitor}, }; pub type VarLongType = i64; diff --git a/pumpkin-protocol/src/lib.rs b/pumpkin-protocol/src/lib.rs index d64ababab..5bda206f9 100644 --- a/pumpkin-protocol/src/lib.rs +++ b/pumpkin-protocol/src/lib.rs @@ -1,9 +1,9 @@ use std::num::NonZeroU16; -use bytebuf::{packet::Packet, ReadingError}; +use bytebuf::{ReadingError, packet::Packet}; use bytes::{Buf, BufMut, Bytes}; use codec::{identifier::Identifier, var_int::VarInt}; -use pumpkin_util::text::{style::Style, TextComponent}; +use pumpkin_util::text::{TextComponent, style::Style}; use serde::{Deserialize, Serialize, Serializer}; pub mod bytebuf; diff --git a/pumpkin-protocol/src/packet_decoder.rs b/pumpkin-protocol/src/packet_decoder.rs index 0f98e3c14..70efa434c 100644 --- a/pumpkin-protocol/src/packet_decoder.rs +++ b/pumpkin-protocol/src/packet_decoder.rs @@ -1,11 +1,11 @@ -use aes::cipher::{generic_array::GenericArray, BlockDecryptMut, BlockSizeUser, KeyIvInit}; +use aes::cipher::{BlockDecryptMut, BlockSizeUser, KeyIvInit, generic_array::GenericArray}; use bytes::{Buf, Bytes, BytesMut}; use libdeflater::{DecompressionError, Decompressor}; use thiserror::Error; use crate::{ + MAX_PACKET_SIZE, RawPacket, VarInt, codec::{Codec, DecodeError}, - RawPacket, VarInt, MAX_PACKET_SIZE, }; type Cipher = cfb8::Decryptor; @@ -193,8 +193,8 @@ mod tests { use super::*; use aes::Aes128; use bytes::BufMut; - use cfb8::cipher::AsyncStreamCipher; use cfb8::Encryptor as Cfb8Encryptor; + use cfb8::cipher::AsyncStreamCipher; use libdeflater::{CompressionLvl, Compressor}; /// Helper function to compress data using libdeflater's Zlib compressor diff --git a/pumpkin-protocol/src/packet_encoder.rs b/pumpkin-protocol/src/packet_encoder.rs index 1ea1f6818..baa040a57 100644 --- a/pumpkin-protocol/src/packet_encoder.rs +++ b/pumpkin-protocol/src/packet_encoder.rs @@ -1,11 +1,11 @@ -use aes::cipher::{generic_array::GenericArray, BlockEncryptMut, BlockSizeUser, KeyIvInit}; +use aes::cipher::{BlockEncryptMut, BlockSizeUser, KeyIvInit, generic_array::GenericArray}; use bytes::{BufMut, BytesMut}; use thiserror::Error; use libdeflater::{CompressionLvl, Compressor}; use crate::{ - codec::Codec, ClientPacket, CompressionLevel, CompressionThreshold, VarInt, MAX_PACKET_SIZE, + ClientPacket, CompressionLevel, CompressionThreshold, MAX_PACKET_SIZE, VarInt, codec::Codec, }; type Cipher = cfb8::Encryptor; @@ -218,8 +218,8 @@ mod tests { use crate::client::status::CStatusResponse; use crate::{bytebuf::packet::Packet, codec::DecodeError}; use aes::Aes128; - use cfb8::cipher::AsyncStreamCipher; use cfb8::Decryptor as Cfb8Decryptor; + use cfb8::cipher::AsyncStreamCipher; use libdeflater::{DecompressionError, Decompressor}; use pumpkin_data::packet::clientbound::STATUS_STATUS_RESPONSE; use pumpkin_macros::client_packet; diff --git a/pumpkin-protocol/src/server/config/cookie_response.rs b/pumpkin-protocol/src/server/config/cookie_response.rs index 3e1f874ea..771ecc392 100644 --- a/pumpkin-protocol/src/server/config/cookie_response.rs +++ b/pumpkin-protocol/src/server/config/cookie_response.rs @@ -3,9 +3,9 @@ use pumpkin_data::packet::serverbound::CONFIG_COOKIE_RESPONSE; use pumpkin_macros::server_packet; use crate::{ + ServerPacket, VarInt, bytebuf::{ByteBuf, ReadingError}, codec::identifier::Identifier, - ServerPacket, VarInt, }; #[server_packet(CONFIG_COOKIE_RESPONSE)] diff --git a/pumpkin-protocol/src/server/config/plugin_message.rs b/pumpkin-protocol/src/server/config/plugin_message.rs index 9aa53ccf9..71fa7de8c 100644 --- a/pumpkin-protocol/src/server/config/plugin_message.rs +++ b/pumpkin-protocol/src/server/config/plugin_message.rs @@ -3,9 +3,9 @@ use pumpkin_data::packet::serverbound::CONFIG_CUSTOM_PAYLOAD; use pumpkin_macros::server_packet; use crate::{ + ServerPacket, bytebuf::{ByteBuf, ReadingError}, codec::identifier::Identifier, - ServerPacket, }; const MAX_PAYLOAD_SIZE: usize = 1048576; diff --git a/pumpkin-protocol/src/server/handshake/mod.rs b/pumpkin-protocol/src/server/handshake/mod.rs index 268bd34ee..c12784acd 100644 --- a/pumpkin-protocol/src/server/handshake/mod.rs +++ b/pumpkin-protocol/src/server/handshake/mod.rs @@ -3,8 +3,8 @@ use pumpkin_data::packet::serverbound::HANDSHAKE_INTENTION; use pumpkin_macros::server_packet; use crate::{ - bytebuf::{ByteBuf, ReadingError}, ConnectionState, ServerPacket, VarInt, + bytebuf::{ByteBuf, ReadingError}, }; #[server_packet(HANDSHAKE_INTENTION)] diff --git a/pumpkin-protocol/src/server/login/cookie_response.rs b/pumpkin-protocol/src/server/login/cookie_response.rs index 1d248b10b..f705d35d6 100644 --- a/pumpkin-protocol/src/server/login/cookie_response.rs +++ b/pumpkin-protocol/src/server/login/cookie_response.rs @@ -1,7 +1,7 @@ use crate::{ + ServerPacket, VarInt, bytebuf::{ByteBuf, ReadingError}, codec::identifier::Identifier, - ServerPacket, VarInt, }; use bytes::Buf; use pumpkin_data::packet::serverbound::LOGIN_COOKIE_RESPONSE; diff --git a/pumpkin-protocol/src/server/login/encryption_response.rs b/pumpkin-protocol/src/server/login/encryption_response.rs index 32efa839c..7d883a52d 100644 --- a/pumpkin-protocol/src/server/login/encryption_response.rs +++ b/pumpkin-protocol/src/server/login/encryption_response.rs @@ -3,8 +3,8 @@ use pumpkin_data::packet::serverbound::LOGIN_KEY; use pumpkin_macros::server_packet; use crate::{ - bytebuf::{ByteBuf, ReadingError}, ServerPacket, VarInt, + bytebuf::{ByteBuf, ReadingError}, }; #[server_packet(LOGIN_KEY)] diff --git a/pumpkin-protocol/src/server/login/login_start.rs b/pumpkin-protocol/src/server/login/login_start.rs index 2e684021f..84ca1ed1a 100644 --- a/pumpkin-protocol/src/server/login/login_start.rs +++ b/pumpkin-protocol/src/server/login/login_start.rs @@ -3,8 +3,8 @@ use pumpkin_data::packet::serverbound::LOGIN_HELLO; use pumpkin_macros::server_packet; use crate::{ - bytebuf::{ByteBuf, ReadingError}, ServerPacket, + bytebuf::{ByteBuf, ReadingError}, }; #[server_packet(LOGIN_HELLO)] diff --git a/pumpkin-protocol/src/server/login/plugin_response.rs b/pumpkin-protocol/src/server/login/plugin_response.rs index 16f5c0850..a06fea453 100644 --- a/pumpkin-protocol/src/server/login/plugin_response.rs +++ b/pumpkin-protocol/src/server/login/plugin_response.rs @@ -1,6 +1,6 @@ use crate::{ - bytebuf::{ByteBuf, ReadingError}, ServerPacket, VarInt, + bytebuf::{ByteBuf, ReadingError}, }; use bytes::{Buf, Bytes}; use pumpkin_data::packet::serverbound::LOGIN_CUSTOM_QUERY_ANSWER; diff --git a/pumpkin-protocol/src/server/play/chat_message.rs b/pumpkin-protocol/src/server/play/chat_message.rs index 0fac277c1..20618f6c2 100644 --- a/pumpkin-protocol/src/server/play/chat_message.rs +++ b/pumpkin-protocol/src/server/play/chat_message.rs @@ -3,8 +3,8 @@ use pumpkin_data::packet::serverbound::PLAY_CHAT; use pumpkin_macros::server_packet; use crate::{ - bytebuf::{ByteBuf, ReadingError}, FixedBitSet, ServerPacket, VarInt, + bytebuf::{ByteBuf, ReadingError}, }; // derive(Deserialize)] diff --git a/pumpkin-protocol/src/server/play/click_container.rs b/pumpkin-protocol/src/server/play/click_container.rs index e155b5be2..bebe8d38d 100644 --- a/pumpkin-protocol/src/server/play/click_container.rs +++ b/pumpkin-protocol/src/server/play/click_container.rs @@ -1,9 +1,9 @@ -use crate::codec::slot::Slot; use crate::VarInt; +use crate::codec::slot::Slot; use pumpkin_data::packet::serverbound::PLAY_CONTAINER_CLICK; use pumpkin_macros::server_packet; use serde::de::SeqAccess; -use serde::{de, Deserialize}; +use serde::{Deserialize, de}; #[server_packet(PLAY_CONTAINER_CLICK)] pub struct SClickContainer { diff --git a/pumpkin-protocol/src/server/play/cookie_response.rs b/pumpkin-protocol/src/server/play/cookie_response.rs index fa26163a2..5a29578e0 100644 --- a/pumpkin-protocol/src/server/play/cookie_response.rs +++ b/pumpkin-protocol/src/server/play/cookie_response.rs @@ -1,7 +1,7 @@ use crate::{ + ServerPacket, VarInt, bytebuf::{ByteBuf, ReadingError}, codec::identifier::Identifier, - ServerPacket, VarInt, }; use bytes::Buf; use pumpkin_data::packet::serverbound::PLAY_COOKIE_RESPONSE; diff --git a/pumpkin-protocol/src/server/play/interact.rs b/pumpkin-protocol/src/server/play/interact.rs index e7a68532d..3373176d8 100644 --- a/pumpkin-protocol/src/server/play/interact.rs +++ b/pumpkin-protocol/src/server/play/interact.rs @@ -4,8 +4,8 @@ use pumpkin_macros::server_packet; use pumpkin_util::math::vector3::Vector3; use crate::{ - bytebuf::{ByteBuf, ReadingError}, ServerPacket, VarInt, + bytebuf::{ByteBuf, ReadingError}, }; #[server_packet(PLAY_INTERACT)] diff --git a/pumpkin-protocol/src/server/play/player_command.rs b/pumpkin-protocol/src/server/play/player_command.rs index a946a07c3..42f489f3f 100644 --- a/pumpkin-protocol/src/server/play/player_command.rs +++ b/pumpkin-protocol/src/server/play/player_command.rs @@ -3,8 +3,8 @@ use pumpkin_data::packet::serverbound::PLAY_PLAYER_COMMAND; use pumpkin_macros::server_packet; use crate::{ - bytebuf::{ByteBuf, ReadingError}, ServerPacket, VarInt, + bytebuf::{ByteBuf, ReadingError}, }; #[server_packet(PLAY_PLAYER_COMMAND)] diff --git a/pumpkin-protocol/src/server/play/update_sign.rs b/pumpkin-protocol/src/server/play/update_sign.rs index 8427ea9fb..57c34e84e 100644 --- a/pumpkin-protocol/src/server/play/update_sign.rs +++ b/pumpkin-protocol/src/server/play/update_sign.rs @@ -4,8 +4,8 @@ use pumpkin_macros::server_packet; use pumpkin_util::math::position::BlockPos; use crate::{ - bytebuf::{ByteBuf, ReadingError}, ServerPacket, + bytebuf::{ByteBuf, ReadingError}, }; #[server_packet(PLAY_SIGN_UPDATE)] diff --git a/pumpkin-registry/src/lib.rs b/pumpkin-registry/src/lib.rs index 0f8391753..f71392182 100644 --- a/pumpkin-registry/src/lib.rs +++ b/pumpkin-registry/src/lib.rs @@ -11,7 +11,7 @@ use instrument::Instrument; use jukebox_song::JukeboxSong; use paint::Painting; use pumpkin_protocol::{client::config::RegistryEntry, codec::identifier::Identifier}; -pub use recipe::{flatten_3x3, Recipe, RecipeResult, RecipeType, RECIPES}; +pub use recipe::{RECIPES, Recipe, RecipeResult, RecipeType, flatten_3x3}; use serde::{Deserialize, Serialize}; use trim_material::TrimMaterial; use trim_pattern::TrimPattern; diff --git a/pumpkin-registry/src/recipe/read.rs b/pumpkin-registry/src/recipe/read.rs index 90664450a..3132f282a 100644 --- a/pumpkin-registry/src/recipe/read.rs +++ b/pumpkin-registry/src/recipe/read.rs @@ -1,13 +1,13 @@ use crate::flatten_3x3; -use crate::recipe::read::ingredients::Ingredients; use crate::recipe::read::SpecialCraftingType::{ ArmorDye, BannerDuplicate, BookCloning, Firework, RepairItem, ShieldDecoration, ShulkerboxColoring, SuspiciousStew, TippedArrow, }; +use crate::recipe::read::ingredients::Ingredients; use crate::recipe::recipe_formats::{ShapedCrafting, ShapelessCrafting}; use pumpkin_data::tag::RegistryEntryList; use serde::de::{Error, MapAccess, Visitor}; -use serde::{de, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de}; use std::collections::HashMap; use std::fmt::Formatter; use std::str::FromStr; diff --git a/pumpkin-util/src/random/legacy_rand.rs b/pumpkin-util/src/random/legacy_rand.rs index 3574bb0de..bf67c51f8 100644 --- a/pumpkin-util/src/random/legacy_rand.rs +++ b/pumpkin-util/src/random/legacy_rand.rs @@ -1,5 +1,5 @@ use super::{ - gaussian::GaussianGenerator, hash_block_pos, java_string_hash, RandomDeriverImpl, RandomImpl, + RandomDeriverImpl, RandomImpl, gaussian::GaussianGenerator, hash_block_pos, java_string_hash, }; pub struct LegacyRand { @@ -121,7 +121,7 @@ impl RandomDeriverImpl for LegacySplitter { #[cfg(test)] mod test { - use crate::random::{legacy_rand::LegacySplitter, RandomDeriverImpl, RandomImpl}; + use crate::random::{RandomDeriverImpl, RandomImpl, legacy_rand::LegacySplitter}; use super::LegacyRand; diff --git a/pumpkin-util/src/random/xoroshiro128.rs b/pumpkin-util/src/random/xoroshiro128.rs index 65d92533c..730942a74 100644 --- a/pumpkin-util/src/random/xoroshiro128.rs +++ b/pumpkin-util/src/random/xoroshiro128.rs @@ -1,4 +1,4 @@ -use super::{gaussian::GaussianGenerator, hash_block_pos, RandomDeriverImpl, RandomImpl}; +use super::{RandomDeriverImpl, RandomImpl, gaussian::GaussianGenerator, hash_block_pos}; pub struct Xoroshiro { lo: u64, @@ -154,7 +154,7 @@ impl RandomDeriverImpl for XoroshiroSplitter { mod tests { use crate::random::{RandomDeriverImpl, RandomImpl}; - use super::{mix_stafford_13, Xoroshiro}; + use super::{Xoroshiro, mix_stafford_13}; // Values checked against results from the equivalent Java source diff --git a/pumpkin-util/src/text/mod.rs b/pumpkin-util/src/text/mod.rs index 5647144e3..61c98fb11 100644 --- a/pumpkin-util/src/text/mod.rs +++ b/pumpkin-util/src/text/mod.rs @@ -266,7 +266,7 @@ pub enum TextContent { mod test { use pumpkin_nbt::serializer::to_bytes_unnamed; - use crate::text::{color::NamedColor, TextComponent}; + use crate::text::{TextComponent, color::NamedColor}; #[test] fn test_serialize_text_component() { diff --git a/pumpkin-world/benches/chunk_noise_populate.rs b/pumpkin-world/benches/chunk_noise_populate.rs index fa113cafd..46d4d11e2 100644 --- a/pumpkin-world/benches/chunk_noise_populate.rs +++ b/pumpkin-world/benches/chunk_noise_populate.rs @@ -1,6 +1,6 @@ -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; use pumpkin_world::{ - bench_create_and_populate_noise, GlobalProtoNoiseRouter, GlobalRandomConfig, NOISE_ROUTER_ASTS, + GlobalProtoNoiseRouter, GlobalRandomConfig, NOISE_ROUTER_ASTS, bench_create_and_populate_noise, }; fn criterion_benchmark(c: &mut Criterion) { diff --git a/pumpkin-world/src/chunk/anvil.rs b/pumpkin-world/src/chunk/anvil.rs index de2aa867b..a7dfa3092 100644 --- a/pumpkin-world/src/chunk/anvil.rs +++ b/pumpkin-world/src/chunk/anvil.rs @@ -427,7 +427,7 @@ impl AnvilChunkFormat { palette: palette .into_iter() .map(|entry| PaletteEntry { - name: entry.1 .0.to_string(), + name: entry.1.0.to_string(), properties: { /* let properties = &get_block(entry.1 .0).unwrap().properties; @@ -505,9 +505,9 @@ mod tests { use temp_dir::TempDir; use crate::chunk::ChunkWriter; - use crate::generation::{get_world_gen, Seed}; + use crate::generation::{Seed, get_world_gen}; use crate::{ - chunk::{anvil::AnvilChunkFormat, ChunkReader, ChunkReadingError}, + chunk::{ChunkReader, ChunkReadingError, anvil::AnvilChunkFormat}, level::LevelFolder, }; diff --git a/pumpkin-world/src/chunk/linear.rs b/pumpkin-world/src/chunk/linear.rs index c8d4c68e0..5a65339ce 100644 --- a/pumpkin-world/src/chunk/linear.rs +++ b/pumpkin-world/src/chunk/linear.rs @@ -464,9 +464,9 @@ mod tests { use temp_dir::TempDir; use crate::chunk::ChunkWriter; - use crate::generation::{get_world_gen, Seed}; + use crate::generation::{Seed, get_world_gen}; use crate::{ - chunk::{linear::LinearChunkFormat, ChunkReader, ChunkReadingError}, + chunk::{ChunkReader, ChunkReadingError, linear::LinearChunkFormat}, level::LevelFolder, }; diff --git a/pumpkin-world/src/chunk/mod.rs b/pumpkin-world/src/chunk/mod.rs index 6b2143a84..5ddc3d129 100644 --- a/pumpkin-world/src/chunk/mod.rs +++ b/pumpkin-world/src/chunk/mod.rs @@ -1,6 +1,6 @@ use dashmap::{ - mapref::one::{Ref, RefMut}, DashMap, + mapref::one::{Ref, RefMut}, }; use pumpkin_data::chunk::ChunkStatus; use pumpkin_nbt::{deserializer::from_bytes, nbt_long_array}; @@ -15,10 +15,10 @@ use std::{ use thiserror::Error; use crate::{ + WORLD_HEIGHT, block::BlockState, coordinates::{ChunkRelativeBlockCoordinates, Height}, level::LevelFolder, - WORLD_HEIGHT, }; pub mod anvil; diff --git a/pumpkin-world/src/generation/aquifer_sampler.rs b/pumpkin-world/src/generation/aquifer_sampler.rs index 0f08c9b5e..0b6b7b569 100644 --- a/pumpkin-world/src/generation/aquifer_sampler.rs +++ b/pumpkin-world/src/generation/aquifer_sampler.rs @@ -14,7 +14,7 @@ use super::{ chunk_noise_router::ChunkNoiseRouter, density_function::{NoisePos, UnblendedNoisePos}, }, - positions::{block_pos, chunk_pos, MIN_HEIGHT_CELL}, + positions::{MIN_HEIGHT_CELL, block_pos, chunk_pos}, proto_chunk::StandardChunkFluidLevelSampler, section_coords, }; @@ -214,18 +214,10 @@ impl WorldAquiferSampler { let o = halved_diff - scaled_level.abs(); let q = if scaled_level > 0f64 { - if o > 0f64 { - o / 1.5f64 - } else { - o / 2.5f64 - } + if o > 0f64 { o / 1.5f64 } else { o / 2.5f64 } } else { let p = 3f64 + o; - if p > 0f64 { - p / 3f64 - } else { - p / 10f64 - } + if p > 0f64 { p / 3f64 } else { p / 10f64 } }; let r = if (-2f64..=2f64).contains(&q) { @@ -661,6 +653,7 @@ mod test { use crate::{ block::BlockState, generation::{ + GlobalRandomConfig, chunk_noise::{ BlockStateSampler, ChainedBlockStateSampler, ChunkNoiseGenerator, ChunkNoiseHeightEstimator, LAVA_BLOCK, WATER_BLOCK, @@ -674,7 +667,6 @@ mod test { }, positions::chunk_pos, proto_chunk::StandardChunkFluidLevelSampler, - GlobalRandomConfig, }, noise_router::NOISE_ROUTER_ASTS, }; diff --git a/pumpkin-world/src/generation/chunk_noise.rs b/pumpkin-world/src/generation/chunk_noise.rs index f39fa4d38..0aa804f79 100644 --- a/pumpkin-world/src/generation/chunk_noise.rs +++ b/pumpkin-world/src/generation/chunk_noise.rs @@ -6,6 +6,7 @@ use pumpkin_util::math::{floor_div, floor_mod, vector2::Vector2}; use crate::{block::BlockState, generation::section_coords}; use super::{ + GlobalRandomConfig, aquifer_sampler::{ AquiferSampler, AquiferSamplerImpl, FluidLevelSampler, SeaLevelAquiferSampler, WorldAquiferSampler, @@ -23,7 +24,6 @@ use super::{ }, ore_sampler::OreVeinSampler, positions::chunk_pos, - GlobalRandomConfig, }; pub const STONE_BLOCK: BlockState = block_state!("stone"); diff --git a/pumpkin-world/src/generation/generic_generator.rs b/pumpkin-world/src/generation/generic_generator.rs index 11e2b8fe8..719276ef4 100644 --- a/pumpkin-world/src/generation/generic_generator.rs +++ b/pumpkin-world/src/generation/generic_generator.rs @@ -2,14 +2,14 @@ use noise::{NoiseFn, Perlin}; use pumpkin_util::math::vector2::Vector2; use crate::{ + WORLD_LOWEST_Y, chunk::{ChunkData, Subchunks}, coordinates::{ChunkRelativeBlockCoordinates, ChunkRelativeXZBlockCoordinates}, - WORLD_LOWEST_Y, }; use super::{ - generator::{BiomeGenerator, GeneratorInit, PerlinTerrainGenerator, WorldGenerator}, Seed, + generator::{BiomeGenerator, GeneratorInit, PerlinTerrainGenerator, WorldGenerator}, }; pub struct GenericGenerator { diff --git a/pumpkin-world/src/generation/implementation/superflat.rs b/pumpkin-world/src/generation/implementation/superflat.rs index 6d28f7aca..08fcb7d2a 100644 --- a/pumpkin-world/src/generation/implementation/superflat.rs +++ b/pumpkin-world/src/generation/implementation/superflat.rs @@ -5,9 +5,9 @@ use crate::{ block::state::BlockState, coordinates::XZBlockCoordinates, generation::{ + Seed, generator::{BiomeGenerator, GeneratorInit, TerrainGenerator}, generic_generator::GenericGenerator, - Seed, }, }; diff --git a/pumpkin-world/src/generation/implementation/test.rs b/pumpkin-world/src/generation/implementation/test.rs index bb25cfa83..60a868e7a 100644 --- a/pumpkin-world/src/generation/implementation/test.rs +++ b/pumpkin-world/src/generation/implementation/test.rs @@ -1,14 +1,14 @@ use pumpkin_util::math::{vector2::Vector2, vector3::Vector3}; use crate::{ + WORLD_LOWEST_Y, WORLD_MAX_Y, chunk::{ChunkData, Subchunks}, coordinates::ChunkRelativeBlockCoordinates, generation::{ - generator::GeneratorInit, noise_router::proto_noise_router::GlobalProtoNoiseRouter, - proto_chunk::ProtoChunk, GlobalRandomConfig, Seed, WorldGenerator, + GlobalRandomConfig, Seed, WorldGenerator, generator::GeneratorInit, + noise_router::proto_noise_router::GlobalProtoNoiseRouter, proto_chunk::ProtoChunk, }, noise_router::NOISE_ROUTER_ASTS, - WORLD_LOWEST_Y, WORLD_MAX_Y, }; pub struct TestGenerator { diff --git a/pumpkin-world/src/generation/mod.rs b/pumpkin-world/src/generation/mod.rs index bfb8a3a98..24a0681ed 100644 --- a/pumpkin-world/src/generation/mod.rs +++ b/pumpkin-world/src/generation/mod.rs @@ -21,7 +21,7 @@ use implementation::{ //overworld::biome::plains::PlainsGenerator, test::TestGenerator, }; -use pumpkin_util::random::{xoroshiro128::Xoroshiro, RandomDeriver, RandomImpl}; +use pumpkin_util::random::{RandomDeriver, RandomImpl, xoroshiro128::Xoroshiro}; pub use seed::Seed; use generator::GeneratorInit; diff --git a/pumpkin-world/src/generation/noise/perlin.rs b/pumpkin-world/src/generation/noise/perlin.rs index 4dc9444cd..8f8e89581 100644 --- a/pumpkin-world/src/generation/noise/perlin.rs +++ b/pumpkin-world/src/generation/noise/perlin.rs @@ -2,7 +2,7 @@ use num_traits::Pow; use pumpkin_data::chunk::DoublePerlinNoiseParameters; use pumpkin_util::random::RandomGenerator; -use super::{lerp3, GRADIENTS}; +use super::{GRADIENTS, lerp3}; #[derive(Clone)] pub struct PerlinNoiseSampler { @@ -357,7 +357,7 @@ mod double_perlin_noise_sampler_test { use crate::generation::noise::perlin::DoublePerlinNoiseSampler; use pumpkin_data::chunk::DoublePerlinNoiseParameters; use pumpkin_util::random::{ - legacy_rand::LegacyRand, xoroshiro128::Xoroshiro, RandomGenerator, RandomImpl, + RandomGenerator, RandomImpl, legacy_rand::LegacyRand, xoroshiro128::Xoroshiro, }; #[test] @@ -560,7 +560,7 @@ mod double_perlin_noise_sampler_test { #[cfg(test)] mod octave_perline_noise_sampler_test { use pumpkin_util::random::{ - legacy_rand::LegacyRand, xoroshiro128::Xoroshiro, RandomGenerator, RandomImpl, + RandomGenerator, RandomImpl, legacy_rand::LegacyRand, xoroshiro128::Xoroshiro, }; use super::OctavePerlinNoiseSampler; @@ -733,7 +733,7 @@ mod perlin_noise_sampler_test { use pumpkin_util::{ assert_eq_delta, - random::{xoroshiro128::Xoroshiro, RandomDeriverImpl, RandomGenerator, RandomImpl}, + random::{RandomDeriverImpl, RandomGenerator, RandomImpl, xoroshiro128::Xoroshiro}, }; use crate::{generation::noise::perlin::PerlinNoiseSampler, read_data_from_file}; @@ -1268,7 +1268,9 @@ mod perlin_noise_sampler_test { assert_eq!(first, -15); assert_eq!( amplitudes, - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] + [ + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 + ] ); } diff --git a/pumpkin-world/src/generation/noise/simplex.rs b/pumpkin-world/src/generation/noise/simplex.rs index 04712de13..114b8d050 100644 --- a/pumpkin-world/src/generation/noise/simplex.rs +++ b/pumpkin-world/src/generation/noise/simplex.rs @@ -1,7 +1,7 @@ use std::hash::Hash; use num_traits::Pow; -use pumpkin_util::random::{legacy_rand::LegacyRand, RandomImpl}; +use pumpkin_util::random::{RandomImpl, legacy_rand::LegacyRand}; use super::GRADIENTS; @@ -274,7 +274,7 @@ impl OctaveSimplexNoiseSampler { #[cfg(test)] mod octave_simplex_noise_sampler_test { - use pumpkin_util::random::{xoroshiro128::Xoroshiro, RandomImpl}; + use pumpkin_util::random::{RandomImpl, xoroshiro128::Xoroshiro}; use crate::generation::noise::simplex::OctaveSimplexNoiseSampler; @@ -410,7 +410,7 @@ mod octave_simplex_noise_sampler_test { #[cfg(test)] mod simplex_noise_sampler_test { - use pumpkin_util::random::{xoroshiro128::Xoroshiro, RandomImpl}; + use pumpkin_util::random::{RandomImpl, xoroshiro128::Xoroshiro}; use crate::generation::noise::simplex::SimplexNoiseSampler; diff --git a/pumpkin-world/src/generation/noise_router/density_function/misc.rs b/pumpkin-world/src/generation/noise_router/density_function/misc.rs index c96b7c2a5..d0823bbc1 100644 --- a/pumpkin-world/src/generation/noise_router/density_function/misc.rs +++ b/pumpkin-world/src/generation/noise_router/density_function/misc.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use pumpkin_util::random::{legacy_rand::LegacyRand, RandomImpl}; +use pumpkin_util::random::{RandomImpl, legacy_rand::LegacyRand}; use crate::{ generation::{ diff --git a/pumpkin-world/src/generation/noise_router/density_function/test.rs b/pumpkin-world/src/generation/noise_router/density_function/test.rs index 914f38178..f905b6417 100644 --- a/pumpkin-world/src/generation/noise_router/density_function/test.rs +++ b/pumpkin-world/src/generation/noise_router/density_function/test.rs @@ -5,6 +5,7 @@ use std::fs; use std::path::Path; use std::sync::LazyLock; +use crate::generation::GlobalRandomConfig; use crate::generation::noise_router::chunk_density_function::{ ChunkNoiseFunctionSampleOptions, SampleAction, }; @@ -12,9 +13,8 @@ use crate::generation::noise_router::chunk_noise_router::{ ChunkNoiseDensityFunction, ChunkNoiseFunctionComponent, }; use crate::generation::noise_router::proto_noise_router::{ - recursive_build_proto_stack, DoublePerlinNoiseBuilder, ProtoNoiseFunctionComponent, + DoublePerlinNoiseBuilder, ProtoNoiseFunctionComponent, recursive_build_proto_stack, }; -use crate::generation::GlobalRandomConfig; use crate::noise_router::NOISE_ROUTER_ASTS; use crate::read_data_from_file; use crate::{ diff --git a/pumpkin-world/src/generation/noise_router/multi_noise_sampler.rs b/pumpkin-world/src/generation/noise_router/multi_noise_sampler.rs index 5a7e9c599..ee01e7510 100644 --- a/pumpkin-world/src/generation/noise_router/multi_noise_sampler.rs +++ b/pumpkin-world/src/generation/noise_router/multi_noise_sampler.rs @@ -1,6 +1,6 @@ use crate::{ - generation::biome_coords, noise_router::density_function_ast::WrapperType, - GlobalProtoNoiseRouter, + GlobalProtoNoiseRouter, generation::biome_coords, + noise_router::density_function_ast::WrapperType, }; use super::{ @@ -187,7 +187,9 @@ impl<'a> MultiNoiseSampler<'a> { )) } _ => { - panic!("These density functions should not be a part of the MultiNoiseSampler! We probably need to re-write code"); + panic!( + "These density functions should not be a part of the MultiNoiseSampler! We probably need to re-write code" + ); } } } diff --git a/pumpkin-world/src/generation/noise_router/proto_noise_router.rs b/pumpkin-world/src/generation/noise_router/proto_noise_router.rs index 93cda967c..7a39e6e7a 100644 --- a/pumpkin-world/src/generation/noise_router/proto_noise_router.rs +++ b/pumpkin-world/src/generation/noise_router/proto_noise_router.rs @@ -7,24 +7,24 @@ use enum_dispatch::enum_dispatch; use pumpkin_data::chunk::DoublePerlinNoiseParameters; use crate::{ + GlobalRandomConfig, generation::noise::perlin::DoublePerlinNoiseSampler, noise_router::{ density_function_ast::{DensityFunctionRepr, SplineRepr}, noise_router_ast::NoiseRouterRepr, }, - GlobalRandomConfig, }; use super::{ chunk_density_function::ChunkNoiseFunctionSampleOptions, chunk_noise_router::{ChunkNoiseFunctionComponent, StaticChunkNoiseFunctionComponentImpl}, density_function::{ + IndexToNoisePos, NoiseFunctionComponentRange, NoisePos, PassThrough, + StaticIndependentChunkNoiseFunctionComponentImpl, Wrapper, math::{Binary, Clamp, Constant, Linear, Unary}, misc::{ClampedYGradient, EndIsland, RangeChoice, WeirdScaled}, noise::{InterpolatedNoiseSampler, Noise, ShiftA, ShiftB, ShiftedNoise}, spline::{Spline, SplineFunction, SplinePoint, SplineValue}, - IndexToNoisePos, NoiseFunctionComponentRange, NoisePos, PassThrough, - StaticIndependentChunkNoiseFunctionComponentImpl, Wrapper, }, }; diff --git a/pumpkin-world/src/generation/positions.rs b/pumpkin-world/src/generation/positions.rs index 6cb79d352..334632978 100644 --- a/pumpkin-world/src/generation/positions.rs +++ b/pumpkin-world/src/generation/positions.rs @@ -4,7 +4,7 @@ pub mod block_pos { use pumpkin_util::math::vector3::Vector3; use super::{ - BITS_X, BITS_Y, BITS_Z, BIT_SHIFT_X, BIT_SHIFT_Z, SIZE_BITS_X, SIZE_BITS_Y, SIZE_BITS_Z, + BIT_SHIFT_X, BIT_SHIFT_Z, BITS_X, BITS_Y, BITS_Z, SIZE_BITS_X, SIZE_BITS_Y, SIZE_BITS_Z, }; #[inline] diff --git a/pumpkin-world/src/generation/proto_chunk.rs b/pumpkin-world/src/generation/proto_chunk.rs index 9884fc888..b83d2156c 100644 --- a/pumpkin-world/src/generation/proto_chunk.rs +++ b/pumpkin-world/src/generation/proto_chunk.rs @@ -8,11 +8,11 @@ use crate::{ }; use super::{ + GlobalRandomConfig, aquifer_sampler::{FluidLevel, FluidLevelSampler, FluidLevelSamplerImpl}, chunk_noise::{ChunkNoiseGenerator, LAVA_BLOCK, STONE_BLOCK, WATER_BLOCK}, noise_router::proto_noise_router::GlobalProtoNoiseRouter, positions::chunk_pos::{start_block_x, start_block_z}, - GlobalRandomConfig, }; pub struct StandardChunkFluidLevelSampler { @@ -239,13 +239,13 @@ mod test { use crate::{ generation::{ + GlobalRandomConfig, noise_router::{ density_function::{NoiseFunctionComponentRange, PassThrough}, proto_noise_router::{GlobalProtoNoiseRouter, ProtoNoiseFunctionComponent}, }, - GlobalRandomConfig, }, - noise_router::{density_function_ast::WrapperType, NOISE_ROUTER_ASTS}, + noise_router::{NOISE_ROUTER_ASTS, density_function_ast::WrapperType}, read_data_from_file, }; diff --git a/pumpkin-world/src/generation/seed.rs b/pumpkin-world/src/generation/seed.rs index fb39f7e32..722098670 100644 --- a/pumpkin-world/src/generation/seed.rs +++ b/pumpkin-world/src/generation/seed.rs @@ -1,4 +1,4 @@ -use pumpkin_util::random::{get_seed, java_string_hash, legacy_rand::LegacyRand, RandomImpl}; +use pumpkin_util::random::{RandomImpl, get_seed, java_string_hash, legacy_rand::LegacyRand}; #[derive(Clone, Copy)] pub struct Seed(pub u64); diff --git a/pumpkin-world/src/level.rs b/pumpkin-world/src/level.rs index 4b1e733f0..728fc9ad9 100644 --- a/pumpkin-world/src/level.rs +++ b/pumpkin-world/src/level.rs @@ -2,24 +2,24 @@ use std::{fs, path::PathBuf, sync::Arc}; use dashmap::{DashMap, Entry}; use num_traits::Zero; -use pumpkin_config::{chunk::ChunkFormat, ADVANCED_CONFIG}; +use pumpkin_config::{ADVANCED_CONFIG, chunk::ChunkFormat}; use pumpkin_util::math::vector2::Vector2; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use tokio::{ runtime::Handle, - sync::{mpsc, RwLock}, + sync::{RwLock, mpsc}, }; use crate::{ chunk::{ - anvil::AnvilChunkFormat, linear::LinearChunkFormat, ChunkData, ChunkParsingError, - ChunkReader, ChunkReadingError, ChunkWriter, + ChunkData, ChunkParsingError, ChunkReader, ChunkReadingError, ChunkWriter, + anvil::AnvilChunkFormat, linear::LinearChunkFormat, }, - generation::{get_world_gen, Seed, WorldGenerator}, - lock::{anvil::AnvilLevelLocker, LevelLocker}, + generation::{Seed, WorldGenerator, get_world_gen}, + lock::{LevelLocker, anvil::AnvilLevelLocker}, world_info::{ - anvil::{AnvilLevelInfo, LEVEL_DAT_BACKUP_FILE_NAME, LEVEL_DAT_FILE_NAME}, LevelData, WorldInfoError, WorldInfoReader, WorldInfoWriter, + anvil::{AnvilLevelInfo, LEVEL_DAT_BACKUP_FILE_NAME, LEVEL_DAT_FILE_NAME}, }, }; diff --git a/pumpkin-world/src/lib.rs b/pumpkin-world/src/lib.rs index 505de580e..d8e58e971 100644 --- a/pumpkin-world/src/lib.rs +++ b/pumpkin-world/src/lib.rs @@ -45,7 +45,7 @@ macro_rules! read_data_from_file { // TODO: is there a way to do in-file benches? pub use generation::{ - noise_router::proto_noise_router::GlobalProtoNoiseRouter, GlobalRandomConfig, + GlobalRandomConfig, noise_router::proto_noise_router::GlobalProtoNoiseRouter, }; pub use noise_router::NOISE_ROUTER_ASTS; diff --git a/pumpkin-world/src/world_info/anvil.rs b/pumpkin-world/src/world_info/anvil.rs index 60d140d1a..5c179e862 100644 --- a/pumpkin-world/src/world_info/anvil.rs +++ b/pumpkin-world/src/world_info/anvil.rs @@ -4,7 +4,7 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -use flate2::{read::GzDecoder, write::GzEncoder, Compression}; +use flate2::{Compression, read::GzDecoder, write::GzEncoder}; use serde::{Deserialize, Serialize}; use crate::{ @@ -125,7 +125,7 @@ mod test { world_info::{DataPacks, LevelData, WorldGenSettings, WorldInfoError, WorldVersion}, }; - use super::{AnvilLevelInfo, LevelDat, WorldInfoReader, WorldInfoWriter, LEVEL_DAT_FILE_NAME}; + use super::{AnvilLevelInfo, LEVEL_DAT_FILE_NAME, LevelDat, WorldInfoReader, WorldInfoWriter}; #[test] fn test_preserve_level_dat_seed() { diff --git a/pumpkin/Cargo.toml b/pumpkin/Cargo.toml index e513da7b8..ff671ec60 100644 --- a/pumpkin/Cargo.toml +++ b/pumpkin/Cargo.toml @@ -2,8 +2,8 @@ name = "pumpkin" version = "0.1.0-dev" description = "Empowering everyone to host fast and efficient Minecraft servers." -edition = "2021" -rust-version = "1.83" +edition.workspace = true +rust-version = "1.85" [package.metadata.tauri-winres] # FileDescription is handled as the Program name by Windows! diff --git a/pumpkin/src/block/blocks/chest.rs b/pumpkin/src/block/blocks/chest.rs index d3be956b4..492d0dd66 100644 --- a/pumpkin/src/block/blocks/chest.rs +++ b/pumpkin/src/block/blocks/chest.rs @@ -8,7 +8,7 @@ use pumpkin_inventory::{Chest, OpenContainer}; use pumpkin_macros::pumpkin_block; use pumpkin_protocol::{client::play::CBlockAction, codec::var_int::VarInt}; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::registry::{get_block, Block}; +use pumpkin_world::block::registry::{Block, get_block}; use crate::{ block::{pumpkin_block::PumpkinBlock, registry::BlockActionResult}, diff --git a/pumpkin/src/block/blocks/lever.rs b/pumpkin/src/block/blocks/lever.rs index 429ec3e06..4ff65c472 100644 --- a/pumpkin/src/block/blocks/lever.rs +++ b/pumpkin/src/block/blocks/lever.rs @@ -4,7 +4,7 @@ use pumpkin_data::item::Item; use pumpkin_macros::pumpkin_block; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use crate::{ block::{properties::Direction, pumpkin_block::PumpkinBlock, registry::BlockActionResult}, diff --git a/pumpkin/src/block/mod.rs b/pumpkin/src/block/mod.rs index 4689e0319..553c2f7f4 100644 --- a/pumpkin/src/block/mod.rs +++ b/pumpkin/src/block/mod.rs @@ -1,5 +1,6 @@ use blocks::{chest::ChestBlock, furnace::FurnaceBlock, lever::LeverBlock}; use properties::{ + BlockPropertiesManager, age::Age, attachment::Attachment, axis::Axis, @@ -14,7 +15,6 @@ use properties::{ slab_type::SlabType, stair_shape::StairShape, waterlog::Waterlogged, - BlockPropertiesManager, }; use pumpkin_data::entity::EntityType; use pumpkin_data::item::Item; diff --git a/pumpkin/src/block/properties/attachment.rs b/pumpkin/src/block/properties/attachment.rs index 39d12f418..698bdddc4 100644 --- a/pumpkin/src/block/properties/attachment.rs +++ b/pumpkin/src/block/properties/attachment.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/axis.rs b/pumpkin/src/block/properties/axis.rs index 615254d4e..b1f700d9e 100644 --- a/pumpkin/src/block/properties/axis.rs +++ b/pumpkin/src/block/properties/axis.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/cardinal.rs b/pumpkin/src/block/properties/cardinal.rs index ee5d90ca5..94dcd6f25 100644 --- a/pumpkin/src/block/properties/cardinal.rs +++ b/pumpkin/src/block/properties/cardinal.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::{position::BlockPos, vector3::Vector3}; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/face.rs b/pumpkin/src/block/properties/face.rs index 3b7735ce4..efdee686b 100644 --- a/pumpkin/src/block/properties/face.rs +++ b/pumpkin/src/block/properties/face.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/facing.rs b/pumpkin/src/block/properties/facing.rs index 558233925..3f54c9b0f 100644 --- a/pumpkin/src/block/properties/facing.rs +++ b/pumpkin/src/block/properties/facing.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/half.rs b/pumpkin/src/block/properties/half.rs index 01964ba83..abfb84c50 100644 --- a/pumpkin/src/block/properties/half.rs +++ b/pumpkin/src/block/properties/half.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/layers.rs b/pumpkin/src/block/properties/layers.rs index bce83b332..a9627d635 100644 --- a/pumpkin/src/block/properties/layers.rs +++ b/pumpkin/src/block/properties/layers.rs @@ -4,8 +4,8 @@ use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; use pumpkin_world::block::{ - registry::{Block, State}, BlockDirection, + registry::{Block, State}, }; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/mod.rs b/pumpkin/src/block/properties/mod.rs index 71494b9c5..d798cd708 100644 --- a/pumpkin/src/block/properties/mod.rs +++ b/pumpkin/src/block/properties/mod.rs @@ -5,8 +5,8 @@ use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; use pumpkin_world::{ block::{ - registry::{Block, State, BLOCKS}, BlockDirection, + registry::{BLOCKS, Block, State}, }, item::ItemStack, }; diff --git a/pumpkin/src/block/properties/signal_fire.rs b/pumpkin/src/block/properties/signal_fire.rs index a739d571e..17d6ccdf3 100644 --- a/pumpkin/src/block/properties/signal_fire.rs +++ b/pumpkin/src/block/properties/signal_fire.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::{position::BlockPos, vector3::Vector3}; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/slab_type.rs b/pumpkin/src/block/properties/slab_type.rs index 355354b9b..89c704ec1 100644 --- a/pumpkin/src/block/properties/slab_type.rs +++ b/pumpkin/src/block/properties/slab_type.rs @@ -4,8 +4,8 @@ use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; use pumpkin_world::block::{ - registry::{Block, State}, BlockDirection, + registry::{Block, State}, }; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/properties/stair_shape.rs b/pumpkin/src/block/properties/stair_shape.rs index be2a3f418..f9e4ae9ae 100644 --- a/pumpkin/src/block/properties/stair_shape.rs +++ b/pumpkin/src/block/properties/stair_shape.rs @@ -1,12 +1,12 @@ use crate::{ - block::properties::{facing::Facing, half::evaluate_half, BlockPropertyMetadata}, + block::properties::{BlockPropertyMetadata, facing::Facing, half::evaluate_half}, world::World, }; use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::{position::BlockPos, vector3::Vector3}; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use super::{BlockProperties, BlockProperty, Direction}; diff --git a/pumpkin/src/block/properties/waterlog.rs b/pumpkin/src/block/properties/waterlog.rs index 04a47ff39..46dc2a787 100644 --- a/pumpkin/src/block/properties/waterlog.rs +++ b/pumpkin/src/block/properties/waterlog.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use pumpkin_macros::block_property; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::{registry::Block, BlockDirection}; +use pumpkin_world::block::{BlockDirection, registry::Block}; use pumpkin_world::item::ItemStack; use super::{BlockProperties, BlockProperty, BlockPropertyMetadata, Direction}; diff --git a/pumpkin/src/block/pumpkin_block.rs b/pumpkin/src/block/pumpkin_block.rs index 5a88ceaf8..729930956 100644 --- a/pumpkin/src/block/pumpkin_block.rs +++ b/pumpkin/src/block/pumpkin_block.rs @@ -7,8 +7,8 @@ use pumpkin_data::item::Item; use pumpkin_inventory::OpenContainer; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::registry::Block; use pumpkin_world::block::BlockDirection; +use pumpkin_world::block::registry::Block; use super::properties::Direction; diff --git a/pumpkin/src/block/registry.rs b/pumpkin/src/block/registry.rs index cb8743d5d..ef1a9f710 100644 --- a/pumpkin/src/block/registry.rs +++ b/pumpkin/src/block/registry.rs @@ -6,8 +6,8 @@ use pumpkin_data::item::Item; use pumpkin_inventory::OpenContainer; use pumpkin_protocol::server::play::SUseItemOn; use pumpkin_util::math::position::BlockPos; -use pumpkin_world::block::registry::Block; use pumpkin_world::block::BlockDirection; +use pumpkin_world::block::registry::Block; use std::collections::HashMap; use std::sync::Arc; diff --git a/pumpkin/src/command/args/block.rs b/pumpkin/src/command/args/block.rs index 8b7b874d4..5debc6506 100644 --- a/pumpkin/src/command/args/block.rs +++ b/pumpkin/src/command/args/block.rs @@ -6,8 +6,8 @@ use crate::{command::dispatcher::CommandError, server::Server}; use super::{ super::{ - args::{ArgumentConsumer, RawArgs}, CommandSender, + args::{ArgumentConsumer, RawArgs}, }, Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; diff --git a/pumpkin/src/command/args/bool.rs b/pumpkin/src/command/args/bool.rs index a304ebec6..9d32680fe 100644 --- a/pumpkin/src/command/args/bool.rs +++ b/pumpkin/src/command/args/bool.rs @@ -1,7 +1,7 @@ +use crate::command::CommandSender; use crate::command::args::{Arg, ArgumentConsumer, FindArg, GetClientSideArgParser}; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; diff --git a/pumpkin/src/command/args/bossbar_color.rs b/pumpkin/src/command/args/bossbar_color.rs index f30e54a90..63882599b 100644 --- a/pumpkin/src/command/args/bossbar_color.rs +++ b/pumpkin/src/command/args/bossbar_color.rs @@ -1,9 +1,9 @@ +use crate::command::CommandSender; use crate::command::args::{ Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use crate::world::bossbar::BossbarColor; use async_trait::async_trait; diff --git a/pumpkin/src/command/args/bossbar_style.rs b/pumpkin/src/command/args/bossbar_style.rs index f06e3c16c..82c6c7d76 100644 --- a/pumpkin/src/command/args/bossbar_style.rs +++ b/pumpkin/src/command/args/bossbar_style.rs @@ -1,9 +1,9 @@ +use crate::command::CommandSender; use crate::command::args::{ Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use crate::world::bossbar::BossbarDivisions; use async_trait::async_trait; diff --git a/pumpkin/src/command/args/bounded_num.rs b/pumpkin/src/command/args/bounded_num.rs index 0d048a5ec..48ae72a0a 100644 --- a/pumpkin/src/command/args/bounded_num.rs +++ b/pumpkin/src/command/args/bounded_num.rs @@ -4,9 +4,9 @@ use std::str::FromStr; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion}; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use super::super::args::ArgumentConsumer; diff --git a/pumpkin/src/command/args/command.rs b/pumpkin/src/command/args/command.rs index 65da1f9ac..f7b7fec16 100644 --- a/pumpkin/src/command/args/command.rs +++ b/pumpkin/src/command/args/command.rs @@ -5,10 +5,10 @@ use pumpkin_protocol::client::play::{ use crate::{ command::{ + CommandSender, args::SplitSingleWhitespaceIncludingEmptyParts, dispatcher::CommandError, tree::{CommandTree, RawArgs}, - CommandSender, }, server::Server, }; diff --git a/pumpkin/src/command/args/damage_type.rs b/pumpkin/src/command/args/damage_type.rs index e40db91a5..30cd141e3 100644 --- a/pumpkin/src/command/args/damage_type.rs +++ b/pumpkin/src/command/args/damage_type.rs @@ -3,10 +3,10 @@ use pumpkin_data::damage::DamageType; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; use crate::command::{ + CommandSender, args::{Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser}, dispatcher::CommandError, tree::RawArgs, - CommandSender, }; use crate::server::Server; diff --git a/pumpkin/src/command/args/entities.rs b/pumpkin/src/command/args/entities.rs index 398680786..ea5c80274 100644 --- a/pumpkin/src/command/args/entities.rs +++ b/pumpkin/src/command/args/entities.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::entity::player::Player; use crate::server::Server; diff --git a/pumpkin/src/command/args/entity.rs b/pumpkin/src/command/args/entity.rs index 24a1a52b2..5016318e9 100644 --- a/pumpkin/src/command/args/entity.rs +++ b/pumpkin/src/command/args/entity.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::entity::player::Player; use crate::server::Server; diff --git a/pumpkin/src/command/args/gamemode.rs b/pumpkin/src/command/args/gamemode.rs index 49b2127d9..24d69708c 100644 --- a/pumpkin/src/command/args/gamemode.rs +++ b/pumpkin/src/command/args/gamemode.rs @@ -5,7 +5,7 @@ use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, Suggestion use pumpkin_util::GameMode; use crate::{ - command::{dispatcher::CommandError, tree::RawArgs, CommandSender}, + command::{CommandSender, dispatcher::CommandError, tree::RawArgs}, server::Server, }; diff --git a/pumpkin/src/command/args/item.rs b/pumpkin/src/command/args/item.rs index 81f61d723..ca6040bbe 100644 --- a/pumpkin/src/command/args/item.rs +++ b/pumpkin/src/command/args/item.rs @@ -6,8 +6,8 @@ use crate::{command::dispatcher::CommandError, server::Server}; use super::{ super::{ - args::{ArgumentConsumer, RawArgs}, CommandSender, + args::{ArgumentConsumer, RawArgs}, }, Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; diff --git a/pumpkin/src/command/args/message.rs b/pumpkin/src/command/args/message.rs index 4cb24d7b9..7ddc09e68 100644 --- a/pumpkin/src/command/args/message.rs +++ b/pumpkin/src/command/args/message.rs @@ -7,8 +7,8 @@ use crate::{command::dispatcher::CommandError, server::Server}; use super::{ super::{ - args::{ArgumentConsumer, RawArgs}, CommandSender, + args::{ArgumentConsumer, RawArgs}, }, Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; diff --git a/pumpkin/src/command/args/mod.rs b/pumpkin/src/command/args/mod.rs index 7bc02729c..9630b4c7a 100644 --- a/pumpkin/src/command/args/mod.rs +++ b/pumpkin/src/command/args/mod.rs @@ -8,14 +8,14 @@ use pumpkin_data::sound::SoundCategory; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; use pumpkin_util::text::TextComponent; use pumpkin_util::{ - math::{position::BlockPos, vector2::Vector2, vector3::Vector3}, GameMode, + math::{position::BlockPos, vector2::Vector2, vector3::Vector3}, }; use super::{ + CommandSender, dispatcher::CommandError, tree::{CommandTree, RawArgs}, - CommandSender, }; use crate::world::bossbar::{BossbarColor, BossbarDivisions}; use crate::{entity::player::Player, server::Server}; diff --git a/pumpkin/src/command/args/particle.rs b/pumpkin/src/command/args/particle.rs index 317375fef..f8c956272 100644 --- a/pumpkin/src/command/args/particle.rs +++ b/pumpkin/src/command/args/particle.rs @@ -3,10 +3,10 @@ use pumpkin_data::particle::Particle; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; use crate::command::{ + CommandSender, args::{Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser}, dispatcher::CommandError, tree::RawArgs, - CommandSender, }; use crate::server::Server; diff --git a/pumpkin/src/command/args/players.rs b/pumpkin/src/command/args/players.rs index 7c71e690b..16b58f9c6 100644 --- a/pumpkin/src/command/args/players.rs +++ b/pumpkin/src/command/args/players.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::entity::player::Player; use crate::server::Server; diff --git a/pumpkin/src/command/args/position_2d.rs b/pumpkin/src/command/args/position_2d.rs index 18c1dc29a..e6c546fbb 100644 --- a/pumpkin/src/command/args/position_2d.rs +++ b/pumpkin/src/command/args/position_2d.rs @@ -3,9 +3,9 @@ use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, Suggestion use pumpkin_util::math::vector2::Vector2; use pumpkin_util::math::vector3::Vector3; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use super::super::args::ArgumentConsumer; diff --git a/pumpkin/src/command/args/position_3d.rs b/pumpkin/src/command/args/position_3d.rs index eba02c4b7..a9848b023 100644 --- a/pumpkin/src/command/args/position_3d.rs +++ b/pumpkin/src/command/args/position_3d.rs @@ -2,9 +2,9 @@ use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; use pumpkin_util::math::vector3::Vector3; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use super::super::args::ArgumentConsumer; diff --git a/pumpkin/src/command/args/position_block.rs b/pumpkin/src/command/args/position_block.rs index 64f95fb33..e9d379fde 100644 --- a/pumpkin/src/command/args/position_block.rs +++ b/pumpkin/src/command/args/position_block.rs @@ -3,9 +3,9 @@ use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, Suggestion use pumpkin_util::math::position::BlockPos; use pumpkin_util::math::vector3::Vector3; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use super::super::args::ArgumentConsumer; diff --git a/pumpkin/src/command/args/resource_location.rs b/pumpkin/src/command/args/resource_location.rs index b6644a313..d9e8ee5c9 100644 --- a/pumpkin/src/command/args/resource_location.rs +++ b/pumpkin/src/command/args/resource_location.rs @@ -1,9 +1,9 @@ +use crate::command::CommandSender; use crate::command::args::{ Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; diff --git a/pumpkin/src/command/args/rotation.rs b/pumpkin/src/command/args/rotation.rs index bc6c414c9..e9546c2a8 100644 --- a/pumpkin/src/command/args/rotation.rs +++ b/pumpkin/src/command/args/rotation.rs @@ -1,9 +1,9 @@ use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use super::super::args::ArgumentConsumer; diff --git a/pumpkin/src/command/args/simple.rs b/pumpkin/src/command/args/simple.rs index 183e70c66..e40b8af51 100644 --- a/pumpkin/src/command/args/simple.rs +++ b/pumpkin/src/command/args/simple.rs @@ -7,8 +7,8 @@ use crate::{command::dispatcher::CommandError, server::Server}; use super::{ super::{ - args::{ArgumentConsumer, RawArgs}, CommandSender, + args::{ArgumentConsumer, RawArgs}, }, Arg, FindArg, GetClientSideArgParser, }; diff --git a/pumpkin/src/command/args/sound.rs b/pumpkin/src/command/args/sound.rs index b3c0ace4a..4763d103c 100644 --- a/pumpkin/src/command/args/sound.rs +++ b/pumpkin/src/command/args/sound.rs @@ -6,8 +6,8 @@ use crate::{command::dispatcher::CommandError, server::Server}; use super::{ super::{ - args::{ArgumentConsumer, RawArgs}, CommandSender, + args::{ArgumentConsumer, RawArgs}, }, Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; diff --git a/pumpkin/src/command/args/sound_category.rs b/pumpkin/src/command/args/sound_category.rs index 6fe531a1a..003f80c80 100644 --- a/pumpkin/src/command/args/sound_category.rs +++ b/pumpkin/src/command/args/sound_category.rs @@ -1,9 +1,9 @@ +use crate::command::CommandSender; use crate::command::args::{ Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use async_trait::async_trait; use pumpkin_data::sound::SoundCategory; diff --git a/pumpkin/src/command/args/summonable_entities.rs b/pumpkin/src/command/args/summonable_entities.rs index 6e86649cb..cf2ec81d4 100644 --- a/pumpkin/src/command/args/summonable_entities.rs +++ b/pumpkin/src/command/args/summonable_entities.rs @@ -6,8 +6,8 @@ use crate::{command::dispatcher::CommandError, server::Server}; use super::{ super::{ - args::{ArgumentConsumer, RawArgs}, CommandSender, + args::{ArgumentConsumer, RawArgs}, }, Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser, }; diff --git a/pumpkin/src/command/args/textcomponent.rs b/pumpkin/src/command/args/textcomponent.rs index 739849c38..731089628 100644 --- a/pumpkin/src/command/args/textcomponent.rs +++ b/pumpkin/src/command/args/textcomponent.rs @@ -1,7 +1,7 @@ +use crate::command::CommandSender; use crate::command::args::{Arg, ArgumentConsumer, FindArg, GetClientSideArgParser}; use crate::command::dispatcher::CommandError; use crate::command::tree::RawArgs; -use crate::command::CommandSender; use crate::server::Server; use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; diff --git a/pumpkin/src/command/args/time.rs b/pumpkin/src/command/args/time.rs index de1fffb39..8ae90380f 100644 --- a/pumpkin/src/command/args/time.rs +++ b/pumpkin/src/command/args/time.rs @@ -2,10 +2,10 @@ use async_trait::async_trait; use pumpkin_protocol::client::play::{ArgumentType, CommandSuggestion, SuggestionProviders}; use crate::command::{ + CommandSender, args::{Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSideArgParser}, dispatcher::CommandError, tree::RawArgs, - CommandSender, }; use crate::server::Server; diff --git a/pumpkin/src/command/commands/ban.rs b/pumpkin/src/command/commands/ban.rs index df2301940..4103710f2 100644 --- a/pumpkin/src/command/commands/ban.rs +++ b/pumpkin/src/command/commands/ban.rs @@ -1,18 +1,18 @@ use crate::{ command::{ - args::{message::MsgArgConsumer, players::PlayersArgumentConsumer, Arg, ConsumedArgs}, - tree::{builder::argument, CommandTree}, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, message::MsgArgConsumer, players::PlayersArgumentConsumer}, + tree::{CommandTree, builder::argument}, }, data::{ - banlist_serializer::BannedPlayerEntry, banned_player_data::BANNED_PLAYER_LIST, - SaveJSONConfiguration, + SaveJSONConfiguration, banlist_serializer::BannedPlayerEntry, + banned_player_data::BANNED_PLAYER_LIST, }, entity::player::Player, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["ban"]; const DESCRIPTION: &str = "bans a player"; diff --git a/pumpkin/src/command/commands/banip.rs b/pumpkin/src/command/commands/banip.rs index fd8330af2..1ba6c79fe 100644 --- a/pumpkin/src/command/commands/banip.rs +++ b/pumpkin/src/command/commands/banip.rs @@ -2,19 +2,19 @@ use std::{net::IpAddr, str::FromStr}; use crate::{ command::{ - args::{message::MsgArgConsumer, simple::SimpleArgConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, message::MsgArgConsumer, simple::SimpleArgConsumer}, + tree::CommandTree, + tree::builder::argument, }, data::{ - banlist_serializer::BannedIpEntry, banned_ip_data::BANNED_IP_LIST, SaveJSONConfiguration, + SaveJSONConfiguration, banlist_serializer::BannedIpEntry, banned_ip_data::BANNED_IP_LIST, }, server::Server, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["ban-ip"]; const DESCRIPTION: &str = "bans a player-ip"; diff --git a/pumpkin/src/command/commands/banlist.rs b/pumpkin/src/command/commands/banlist.rs index f5f09b709..f1cb7ebdf 100644 --- a/pumpkin/src/command/commands/banlist.rs +++ b/pumpkin/src/command/commands/banlist.rs @@ -1,15 +1,15 @@ use crate::{ command::{ - args::{simple::SimpleArgConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, simple::SimpleArgConsumer}, + tree::CommandTree, + tree::builder::argument, }, data::{banned_ip_data::BANNED_IP_LIST, banned_player_data::BANNED_PLAYER_LIST}, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["banlist"]; const DESCRIPTION: &str = "shows the banlist"; @@ -66,7 +66,7 @@ impl CommandExecutor for BanListExecutor { _ => { return Err(CommandError::GeneralCommandIssue( "Incorrect argument for command".to_string(), - )) + )); } } diff --git a/pumpkin/src/command/commands/bossbar.rs b/pumpkin/src/command/commands/bossbar.rs index a2d9bcea2..62a8fc17e 100644 --- a/pumpkin/src/command/commands/bossbar.rs +++ b/pumpkin/src/command/commands/bossbar.rs @@ -9,16 +9,16 @@ use crate::command::args::{ConsumedArgs, FindArg, FindArgDefaultName}; use crate::command::dispatcher::CommandError; use crate::command::args::textcomponent::TextComponentArgConsumer; -use crate::command::tree::builder::{argument, argument_default_name, literal}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, argument_default_name, literal}; use crate::command::{CommandExecutor, CommandSender}; use crate::server::Server; use crate::world::bossbar::Bossbar; use crate::world::custom_bossbar::BossbarUpdateError; use async_trait::async_trait; +use pumpkin_util::text::TextComponent; use pumpkin_util::text::color::{Color, NamedColor}; use pumpkin_util::text::hover::HoverEvent; -use pumpkin_util::text::TextComponent; use uuid::Uuid; const NAMES: [&str; 1] = ["bossbar"]; diff --git a/pumpkin/src/command/commands/clear.rs b/pumpkin/src/command/commands/clear.rs index 478be7886..86f9441bd 100644 --- a/pumpkin/src/command/commands/clear.rs +++ b/pumpkin/src/command/commands/clear.rs @@ -2,15 +2,15 @@ use std::sync::Arc; use async_trait::async_trait; use pumpkin_inventory::Container; +use pumpkin_util::text::TextComponent; use pumpkin_util::text::click::ClickEvent; use pumpkin_util::text::color::NamedColor; use pumpkin_util::text::hover::HoverEvent; -use pumpkin_util::text::TextComponent; use crate::command::args::entities::EntitiesArgumentConsumer; use crate::command::args::{Arg, ConsumedArgs}; -use crate::command::tree::builder::{argument, require}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, require}; use crate::command::{CommandError, CommandExecutor, CommandSender}; use crate::entity::player::Player; use CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/damage.rs b/pumpkin/src/command/commands/damage.rs index dbe4537d7..53406fdbb 100644 --- a/pumpkin/src/command/commands/damage.rs +++ b/pumpkin/src/command/commands/damage.rs @@ -1,19 +1,19 @@ use async_trait::async_trait; use pumpkin_data::damage::DamageType; use pumpkin_util::text::{ - color::{Color, NamedColor}, TextComponent, + color::{Color, NamedColor}, }; use crate::command::{ + CommandError, CommandExecutor, CommandSender, args::{ - bounded_num::BoundedNumArgumentConsumer, damage_type::DamageTypeArgumentConsumer, - entity::EntityArgumentConsumer, position_3d::Position3DArgumentConsumer, Arg, ConsumedArgs, - FindArg, + Arg, ConsumedArgs, FindArg, bounded_num::BoundedNumArgumentConsumer, + damage_type::DamageTypeArgumentConsumer, entity::EntityArgumentConsumer, + position_3d::Position3DArgumentConsumer, }, - tree::builder::{argument, literal}, tree::CommandTree, - CommandError, CommandExecutor, CommandSender, + tree::builder::{argument, literal}, }; const NAMES: [&str; 1] = ["damage"]; diff --git a/pumpkin/src/command/commands/deop.rs b/pumpkin/src/command/commands/deop.rs index ce6e98661..97960de3f 100644 --- a/pumpkin/src/command/commands/deop.rs +++ b/pumpkin/src/command/commands/deop.rs @@ -1,15 +1,15 @@ use crate::{ command::{ - args::{players::PlayersArgumentConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, players::PlayersArgumentConsumer}, + tree::CommandTree, + tree::builder::argument, }, - data::{op_data::OPERATOR_CONFIG, SaveJSONConfiguration}, + data::{SaveJSONConfiguration, op_data::OPERATOR_CONFIG}, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["deop"]; const DESCRIPTION: &str = "Revokes operator status from a player."; diff --git a/pumpkin/src/command/commands/experience.rs b/pumpkin/src/command/commands/experience.rs index 73cf9633a..59f5f96f1 100644 --- a/pumpkin/src/command/commands/experience.rs +++ b/pumpkin/src/command/commands/experience.rs @@ -2,14 +2,14 @@ use std::sync::atomic::Ordering; use async_trait::async_trait; use pumpkin_util::math::experience; -use pumpkin_util::text::color::{Color, NamedColor}; use pumpkin_util::text::TextComponent; +use pumpkin_util::text::color::{Color, NamedColor}; use crate::command::args::bounded_num::BoundedNumArgumentConsumer; use crate::command::args::players::PlayersArgumentConsumer; use crate::command::args::{ConsumedArgs, FindArg}; -use crate::command::tree::builder::{argument, literal}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, literal}; use crate::command::{CommandError, CommandExecutor, CommandSender}; use crate::entity::player::Player; diff --git a/pumpkin/src/command/commands/fill.rs b/pumpkin/src/command/commands/fill.rs index 6fada48b6..db423d3d1 100644 --- a/pumpkin/src/command/commands/fill.rs +++ b/pumpkin/src/command/commands/fill.rs @@ -1,8 +1,8 @@ use crate::command::args::block::BlockArgumentConsumer; use crate::command::args::position_block::BlockPosArgumentConsumer; use crate::command::args::{ConsumedArgs, FindArg}; -use crate::command::tree::builder::{argument, literal}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, literal}; use crate::command::{CommandError, CommandExecutor, CommandSender}; use async_trait::async_trait; diff --git a/pumpkin/src/command/commands/gamemode.rs b/pumpkin/src/command/commands/gamemode.rs index 016bd8eb6..1ff623095 100644 --- a/pumpkin/src/command/commands/gamemode.rs +++ b/pumpkin/src/command/commands/gamemode.rs @@ -1,18 +1,18 @@ use async_trait::async_trait; -use crate::command::args::gamemode::GamemodeArgumentConsumer; use crate::command::args::GetCloned; +use crate::command::args::gamemode::GamemodeArgumentConsumer; use crate::TextComponent; use crate::command::args::players::PlayersArgumentConsumer; +use crate::command::CommandSender::Player; use crate::command::args::{Arg, ConsumedArgs}; use crate::command::dispatcher::CommandError; use crate::command::dispatcher::CommandError::{InvalidConsumption, InvalidRequirement}; -use crate::command::tree::builder::{argument, require}; use crate::command::tree::CommandTree; -use crate::command::CommandSender::Player; +use crate::command::tree::builder::{argument, require}; use crate::command::{CommandExecutor, CommandSender}; use crate::server::Server; diff --git a/pumpkin/src/command/commands/give.rs b/pumpkin/src/command/commands/give.rs index 9c2184383..c09cd917d 100644 --- a/pumpkin/src/command/commands/give.rs +++ b/pumpkin/src/command/commands/give.rs @@ -1,15 +1,15 @@ use async_trait::async_trait; +use pumpkin_util::text::TextComponent; use pumpkin_util::text::click::ClickEvent; use pumpkin_util::text::color::{Color, NamedColor}; use pumpkin_util::text::hover::HoverEvent; -use pumpkin_util::text::TextComponent; use crate::command::args::bounded_num::BoundedNumArgumentConsumer; use crate::command::args::item::ItemArgumentConsumer; use crate::command::args::players::PlayersArgumentConsumer; use crate::command::args::{ConsumedArgs, FindArg, FindArgDefaultName}; -use crate::command::tree::builder::{argument, argument_default_name}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, argument_default_name}; use crate::command::{CommandError, CommandExecutor, CommandSender}; const NAMES: [&str; 1] = ["give"]; diff --git a/pumpkin/src/command/commands/help.rs b/pumpkin/src/command/commands/help.rs index ea7184811..cb0fbc4d9 100644 --- a/pumpkin/src/command/commands/help.rs +++ b/pumpkin/src/command/commands/help.rs @@ -1,7 +1,7 @@ use async_trait::async_trait; +use pumpkin_util::text::TextComponent; use pumpkin_util::text::click::ClickEvent; use pumpkin_util::text::color::{Color, NamedColor}; -use pumpkin_util::text::TextComponent; use crate::command::args::bounded_num::BoundedNumArgumentConsumer; use crate::command::args::command::CommandTreeArgumentConsumer; @@ -132,7 +132,7 @@ impl CommandExecutor for BaseHelpExecutor { dispatcher .permissions .get(&tree.names[0]) - .map_or(true, |perm| sender.has_permission_lvl(*perm)) + .is_none_or(|perm| sender.has_permission_lvl(*perm)) }) .collect(); diff --git a/pumpkin/src/command/commands/kick.rs b/pumpkin/src/command/commands/kick.rs index c0d3c492d..ed3641e52 100644 --- a/pumpkin/src/command/commands/kick.rs +++ b/pumpkin/src/command/commands/kick.rs @@ -1,13 +1,13 @@ use async_trait::async_trait; -use pumpkin_util::text::color::NamedColor; use pumpkin_util::text::TextComponent; +use pumpkin_util::text::color::NamedColor; +use crate::command::CommandError; use crate::command::args::message::MsgArgConsumer; use crate::command::args::players::PlayersArgumentConsumer; use crate::command::args::{Arg, ConsumedArgs}; -use crate::command::tree::builder::argument; use crate::command::tree::CommandTree; -use crate::command::CommandError; +use crate::command::tree::builder::argument; use crate::command::{CommandExecutor, CommandSender}; use CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/kill.rs b/pumpkin/src/command/commands/kill.rs index 03ffd16ce..4f372b9b1 100644 --- a/pumpkin/src/command/commands/kill.rs +++ b/pumpkin/src/command/commands/kill.rs @@ -1,13 +1,13 @@ use async_trait::async_trait; use pumpkin_data::entity; +use pumpkin_util::text::TextComponent; use pumpkin_util::text::click::ClickEvent; use pumpkin_util::text::hover::HoverEvent; -use pumpkin_util::text::TextComponent; use crate::command::args::entities::EntitiesArgumentConsumer; use crate::command::args::{Arg, ConsumedArgs}; -use crate::command::tree::builder::{argument, require}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, require}; use crate::command::{CommandError, CommandExecutor, CommandSender}; use CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/list.rs b/pumpkin/src/command/commands/list.rs index b1cc81621..cd94feea3 100644 --- a/pumpkin/src/command/commands/list.rs +++ b/pumpkin/src/command/commands/list.rs @@ -6,7 +6,7 @@ use pumpkin_util::text::TextComponent; use crate::{ command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, + CommandError, CommandExecutor, CommandSender, args::ConsumedArgs, tree::CommandTree, }, entity::player::Player, }; diff --git a/pumpkin/src/command/commands/me.rs b/pumpkin/src/command/commands/me.rs index ad51b854c..7b6f70026 100644 --- a/pumpkin/src/command/commands/me.rs +++ b/pumpkin/src/command/commands/me.rs @@ -3,10 +3,10 @@ use pumpkin_data::world::EMOTE_COMMAND; use pumpkin_util::text::TextComponent; use crate::command::{ - args::{message::MsgArgConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, message::MsgArgConsumer}, + tree::CommandTree, + tree::builder::argument, }; use CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/msg.rs b/pumpkin/src/command/commands/msg.rs index af235bea1..028aae52b 100644 --- a/pumpkin/src/command/commands/msg.rs +++ b/pumpkin/src/command/commands/msg.rs @@ -1,15 +1,15 @@ use async_trait::async_trait; use pumpkin_data::world::{MSG_COMMAND_INCOMING, MSG_COMMAND_OUTGOING}; -use pumpkin_util::text::{click::ClickEvent, hover::HoverEvent, TextComponent}; +use pumpkin_util::text::{TextComponent, click::ClickEvent, hover::HoverEvent}; use crate::command::{ + CommandError, CommandExecutor, CommandSender, args::{ - message::MsgArgConsumer, players::PlayersArgumentConsumer, Arg, ConsumedArgs, - FindArgDefaultName, + Arg, ConsumedArgs, FindArgDefaultName, message::MsgArgConsumer, + players::PlayersArgumentConsumer, }, - tree::builder::{argument, argument_default_name}, tree::CommandTree, - CommandError, CommandExecutor, CommandSender, + tree::builder::{argument, argument_default_name}, }; use CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/op.rs b/pumpkin/src/command/commands/op.rs index 8fae81ba4..56f430acf 100644 --- a/pumpkin/src/command/commands/op.rs +++ b/pumpkin/src/command/commands/op.rs @@ -1,16 +1,16 @@ use crate::{ command::{ - args::{players::PlayersArgumentConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, players::PlayersArgumentConsumer}, + tree::CommandTree, + tree::builder::argument, }, - data::{op_data::OPERATOR_CONFIG, SaveJSONConfiguration}, + data::{SaveJSONConfiguration, op_data::OPERATOR_CONFIG}, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; -use pumpkin_config::{op::Op, BASIC_CONFIG}; +use pumpkin_config::{BASIC_CONFIG, op::Op}; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["op"]; const DESCRIPTION: &str = "Grants operator status to a player."; diff --git a/pumpkin/src/command/commands/pardon.rs b/pumpkin/src/command/commands/pardon.rs index 5fb79cb23..46d928dbd 100644 --- a/pumpkin/src/command/commands/pardon.rs +++ b/pumpkin/src/command/commands/pardon.rs @@ -1,15 +1,15 @@ use crate::{ command::{ - args::{simple::SimpleArgConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, simple::SimpleArgConsumer}, + tree::CommandTree, + tree::builder::argument, }, - data::{banned_player_data::BANNED_PLAYER_LIST, SaveJSONConfiguration}, + data::{SaveJSONConfiguration, banned_player_data::BANNED_PLAYER_LIST}, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["pardon"]; const DESCRIPTION: &str = "unbans a player"; diff --git a/pumpkin/src/command/commands/pardonip.rs b/pumpkin/src/command/commands/pardonip.rs index 2ca2b2e71..b467d0fa3 100644 --- a/pumpkin/src/command/commands/pardonip.rs +++ b/pumpkin/src/command/commands/pardonip.rs @@ -2,16 +2,16 @@ use std::{net::IpAddr, str::FromStr}; use crate::{ command::{ - args::{simple::SimpleArgConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, simple::SimpleArgConsumer}, + tree::CommandTree, + tree::builder::argument, }, - data::{banned_ip_data::BANNED_IP_LIST, SaveJSONConfiguration}, + data::{SaveJSONConfiguration, banned_ip_data::BANNED_IP_LIST}, }; +use CommandError::InvalidConsumption; use async_trait::async_trait; use pumpkin_util::text::TextComponent; -use CommandError::InvalidConsumption; const NAMES: [&str; 1] = ["pardon-ip"]; const DESCRIPTION: &str = "unbans a ip"; diff --git a/pumpkin/src/command/commands/particle.rs b/pumpkin/src/command/commands/particle.rs index 934f05c45..7e50b95ca 100644 --- a/pumpkin/src/command/commands/particle.rs +++ b/pumpkin/src/command/commands/particle.rs @@ -2,12 +2,12 @@ use async_trait::async_trait; use pumpkin_util::{math::vector3::Vector3, text::TextComponent}; use crate::command::{ + CommandError, CommandExecutor, CommandSender, args::{ - bounded_num::BoundedNumArgumentConsumer, particle::ParticleArgumentConsumer, - position_3d::Position3DArgumentConsumer, ConsumedArgs, FindArg, + ConsumedArgs, FindArg, bounded_num::BoundedNumArgumentConsumer, + particle::ParticleArgumentConsumer, position_3d::Position3DArgumentConsumer, }, - tree::{builder::argument, CommandTree}, - CommandError, CommandExecutor, CommandSender, + tree::{CommandTree, builder::argument}, }; const NAMES: [&str; 1] = ["particle"]; diff --git a/pumpkin/src/command/commands/playsound.rs b/pumpkin/src/command/commands/playsound.rs index 6f82a393a..f1321eeaa 100644 --- a/pumpkin/src/command/commands/playsound.rs +++ b/pumpkin/src/command/commands/playsound.rs @@ -1,17 +1,17 @@ use async_trait::async_trait; use pumpkin_data::sound::SoundCategory; use pumpkin_util::text::TextComponent; -use rand::{thread_rng, Rng}; +use rand::{Rng, thread_rng}; use crate::command::{ + CommandError, CommandExecutor, CommandSender, args::{ - bounded_num::BoundedNumArgumentConsumer, players::PlayersArgumentConsumer, - position_3d::Position3DArgumentConsumer, sound::SoundArgumentConsumer, - sound_category::SoundCategoryArgumentConsumer, Arg, ConsumedArgs, FindArg, + Arg, ConsumedArgs, FindArg, bounded_num::BoundedNumArgumentConsumer, + players::PlayersArgumentConsumer, position_3d::Position3DArgumentConsumer, + sound::SoundArgumentConsumer, sound_category::SoundCategoryArgumentConsumer, }, - tree::builder::argument, tree::CommandTree, - CommandError, CommandExecutor, CommandSender, + tree::builder::argument, }; /// Command: playsound [] [] [] [] [] [] @@ -109,7 +109,7 @@ impl CommandExecutor for SoundExecutor { }; // Use same random seed for all targets to ensure sound synchronization - let seed = thread_rng().gen::(); + let seed = thread_rng().r#gen::(); // Track how many players actually received the sound let mut players_who_heard = 0; diff --git a/pumpkin/src/command/commands/plugin.rs b/pumpkin/src/command/commands/plugin.rs index eefccc1e9..359c6820d 100644 --- a/pumpkin/src/command/commands/plugin.rs +++ b/pumpkin/src/command/commands/plugin.rs @@ -1,19 +1,19 @@ use async_trait::async_trait; use pumpkin_util::{ - text::{color::NamedColor, hover::HoverEvent, TextComponent}, PermissionLvl, + text::{TextComponent, color::NamedColor, hover::HoverEvent}, }; use crate::{ + PLUGIN_MANAGER, command::{ - args::{simple::SimpleArgConsumer, Arg, ConsumedArgs}, + CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, simple::SimpleArgConsumer}, tree::{ - builder::{argument, literal, require}, CommandTree, + builder::{argument, literal, require}, }, - CommandError, CommandExecutor, CommandSender, }, - PLUGIN_MANAGER, }; use crate::command::CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/plugins.rs b/pumpkin/src/command/commands/plugins.rs index 2d824b21b..a94400717 100644 --- a/pumpkin/src/command/commands/plugins.rs +++ b/pumpkin/src/command/commands/plugins.rs @@ -1,11 +1,11 @@ use async_trait::async_trait; -use pumpkin_util::text::{color::NamedColor, hover::HoverEvent, TextComponent}; +use pumpkin_util::text::{TextComponent, color::NamedColor, hover::HoverEvent}; use crate::{ + PLUGIN_MANAGER, command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, + CommandError, CommandExecutor, CommandSender, args::ConsumedArgs, tree::CommandTree, }, - PLUGIN_MANAGER, }; const NAMES: [&str; 1] = ["plugins"]; diff --git a/pumpkin/src/command/commands/pumpkin.rs b/pumpkin/src/command/commands/pumpkin.rs index f250ac7e1..fae9793cf 100644 --- a/pumpkin/src/command/commands/pumpkin.rs +++ b/pumpkin/src/command/commands/pumpkin.rs @@ -2,15 +2,15 @@ use async_trait::async_trait; use pumpkin_protocol::CURRENT_MC_PROTOCOL; use pumpkin_util::text::click::ClickEvent; use pumpkin_util::text::hover::HoverEvent; -use pumpkin_util::text::{color::NamedColor, TextComponent}; +use pumpkin_util::text::{TextComponent, color::NamedColor}; use std::borrow::Cow; use crate::{ + GIT_VERSION, command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, + CommandError, CommandExecutor, CommandSender, args::ConsumedArgs, tree::CommandTree, }, server::CURRENT_MC_VERSION, - GIT_VERSION, }; const NAMES: [&str; 2] = ["pumpkin", "version"]; diff --git a/pumpkin/src/command/commands/say.rs b/pumpkin/src/command/commands/say.rs index 24e2de2ee..fcea13ea7 100644 --- a/pumpkin/src/command/commands/say.rs +++ b/pumpkin/src/command/commands/say.rs @@ -3,10 +3,10 @@ use pumpkin_data::world::SAY_COMMAND; use pumpkin_util::text::TextComponent; use crate::command::{ - args::{message::MsgArgConsumer, Arg, ConsumedArgs}, - tree::builder::argument, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{Arg, ConsumedArgs, message::MsgArgConsumer}, + tree::CommandTree, + tree::builder::argument, }; use CommandError::InvalidConsumption; diff --git a/pumpkin/src/command/commands/seed.rs b/pumpkin/src/command/commands/seed.rs index 15ae52761..7d908839f 100644 --- a/pumpkin/src/command/commands/seed.rs +++ b/pumpkin/src/command/commands/seed.rs @@ -1,10 +1,10 @@ use crate::command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, + CommandError, CommandExecutor, CommandSender, args::ConsumedArgs, tree::CommandTree, }; use async_trait::async_trait; use pumpkin_util::text::click::ClickEvent; use pumpkin_util::text::hover::HoverEvent; -use pumpkin_util::text::{color::NamedColor, TextComponent}; +use pumpkin_util::text::{TextComponent, color::NamedColor}; use std::borrow::Cow; const NAMES: [&str; 1] = ["seed"]; @@ -31,7 +31,7 @@ impl CommandExecutor for PumpkinExecutor { None => { return Err(CommandError::GeneralCommandIssue( "Unable to get Seed".to_string(), - )) + )); } }, }; diff --git a/pumpkin/src/command/commands/setblock.rs b/pumpkin/src/command/commands/setblock.rs index 20f218734..dfaf0edf0 100644 --- a/pumpkin/src/command/commands/setblock.rs +++ b/pumpkin/src/command/commands/setblock.rs @@ -4,8 +4,8 @@ use pumpkin_util::text::TextComponent; use crate::command::args::block::BlockArgumentConsumer; use crate::command::args::position_block::BlockPosArgumentConsumer; use crate::command::args::{ConsumedArgs, FindArg}; -use crate::command::tree::builder::{argument, literal}; use crate::command::tree::CommandTree; +use crate::command::tree::builder::{argument, literal}; use crate::command::{CommandError, CommandExecutor, CommandSender}; const NAMES: [&str; 1] = ["setblock"]; diff --git a/pumpkin/src/command/commands/stop.rs b/pumpkin/src/command/commands/stop.rs index c8891b1e1..a452f6430 100644 --- a/pumpkin/src/command/commands/stop.rs +++ b/pumpkin/src/command/commands/stop.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; -use pumpkin_util::text::color::NamedColor; use pumpkin_util::text::TextComponent; +use pumpkin_util::text::color::NamedColor; use crate::command::args::ConsumedArgs; use crate::command::tree::CommandTree; diff --git a/pumpkin/src/command/commands/summon.rs b/pumpkin/src/command/commands/summon.rs index c6f5ca815..4dab2133e 100644 --- a/pumpkin/src/command/commands/summon.rs +++ b/pumpkin/src/command/commands/summon.rs @@ -3,13 +3,13 @@ use pumpkin_util::text::TextComponent; use crate::{ command::{ + CommandError, CommandExecutor, CommandSender, args::{ - position_3d::Position3DArgumentConsumer, - summonable_entities::SummonableEntitiesArgumentConsumer, ConsumedArgs, FindArg, + ConsumedArgs, FindArg, position_3d::Position3DArgumentConsumer, + summonable_entities::SummonableEntitiesArgumentConsumer, }, - tree::builder::argument, tree::CommandTree, - CommandError, CommandExecutor, CommandSender, + tree::builder::argument, }, entity::mob, }; diff --git a/pumpkin/src/command/commands/teleport.rs b/pumpkin/src/command/commands/teleport.rs index c2e53fdae..cdb14e377 100644 --- a/pumpkin/src/command/commands/teleport.rs +++ b/pumpkin/src/command/commands/teleport.rs @@ -2,15 +2,15 @@ use async_trait::async_trait; use pumpkin_util::math::vector3::Vector3; use pumpkin_util::text::TextComponent; +use crate::command::CommandError; +use crate::command::args::ConsumedArgs; +use crate::command::args::FindArg; use crate::command::args::entities::EntitiesArgumentConsumer; use crate::command::args::entity::EntityArgumentConsumer; use crate::command::args::position_3d::Position3DArgumentConsumer; use crate::command::args::rotation::RotationArgumentConsumer; -use crate::command::args::ConsumedArgs; -use crate::command::args::FindArg; -use crate::command::tree::builder::{argument, literal}; use crate::command::tree::CommandTree; -use crate::command::CommandError; +use crate::command::tree::builder::{argument, literal}; use crate::command::{CommandExecutor, CommandSender}; const NAMES: [&str; 2] = ["teleport", "tp"]; diff --git a/pumpkin/src/command/commands/time.rs b/pumpkin/src/command/commands/time.rs index e2e5b8658..0a3fc1b13 100644 --- a/pumpkin/src/command/commands/time.rs +++ b/pumpkin/src/command/commands/time.rs @@ -1,11 +1,11 @@ use async_trait::async_trait; -use pumpkin_util::text::color::{Color, NamedColor}; use pumpkin_util::text::TextComponent; +use pumpkin_util::text::color::{Color, NamedColor}; -use crate::command::args::{time::TimeArgumentConsumer, FindArg}; +use crate::command::args::{FindArg, time::TimeArgumentConsumer}; use crate::command::tree::builder::{argument, literal}; use crate::command::{ - tree::CommandTree, CommandError, CommandExecutor, CommandSender, ConsumedArgs, + CommandError, CommandExecutor, CommandSender, ConsumedArgs, tree::CommandTree, }; const NAMES: [&str; 1] = ["time"]; diff --git a/pumpkin/src/command/commands/title.rs b/pumpkin/src/command/commands/title.rs index 751410842..f845c4f83 100644 --- a/pumpkin/src/command/commands/title.rs +++ b/pumpkin/src/command/commands/title.rs @@ -4,13 +4,13 @@ use pumpkin_util::text::TextComponent; use crate::{ command::{ + CommandError, CommandExecutor, CommandSender, args::{ - players::PlayersArgumentConsumer, textcomponent::TextComponentArgConsumer, Arg, - ConsumedArgs, FindArg, + Arg, ConsumedArgs, FindArg, players::PlayersArgumentConsumer, + textcomponent::TextComponentArgConsumer, }, - tree::builder::{argument, literal}, tree::CommandTree, - CommandError, CommandExecutor, CommandSender, + tree::builder::{argument, literal}, }, entity::player::TitleMode, }; diff --git a/pumpkin/src/command/commands/transfer.rs b/pumpkin/src/command/commands/transfer.rs index e456c9d74..13848e8f5 100644 --- a/pumpkin/src/command/commands/transfer.rs +++ b/pumpkin/src/command/commands/transfer.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; use pumpkin_protocol::client::play::CTransfer; use pumpkin_protocol::codec::var_int::VarInt; -use pumpkin_util::text::color::{Color, NamedColor}; use pumpkin_util::text::TextComponent; +use pumpkin_util::text::color::{Color, NamedColor}; use crate::command::args::bounded_num::BoundedNumArgumentConsumer; use crate::command::args::players::PlayersArgumentConsumer; @@ -11,7 +11,7 @@ use crate::command::args::{Arg, FindArgDefaultName}; use crate::command::dispatcher::CommandError::{InvalidConsumption, InvalidRequirement}; use crate::command::tree::builder::{argument, argument_default_name, require}; use crate::command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, + CommandError, CommandExecutor, CommandSender, args::ConsumedArgs, tree::CommandTree, }; const NAMES: [&str; 1] = ["transfer"]; diff --git a/pumpkin/src/command/commands/weather.rs b/pumpkin/src/command/commands/weather.rs index e66241852..8a5726ec1 100644 --- a/pumpkin/src/command/commands/weather.rs +++ b/pumpkin/src/command/commands/weather.rs @@ -2,10 +2,10 @@ use async_trait::async_trait; use pumpkin_util::text::TextComponent; use crate::command::{ - args::{time::TimeArgumentConsumer, ConsumedArgs, FindArg}, - tree::builder::{argument, literal}, - tree::CommandTree, CommandError, CommandExecutor, CommandSender, + args::{ConsumedArgs, FindArg, time::TimeArgumentConsumer}, + tree::CommandTree, + tree::builder::{argument, literal}, }; const NAMES: [&str; 1] = ["weather"]; diff --git a/pumpkin/src/command/commands/worldborder.rs b/pumpkin/src/command/commands/worldborder.rs index 9f454c67a..4f534b00e 100644 --- a/pumpkin/src/command/commands/worldborder.rs +++ b/pumpkin/src/command/commands/worldborder.rs @@ -2,20 +2,20 @@ use async_trait::async_trait; use pumpkin_util::{ math::vector2::Vector2, text::{ - color::{Color, NamedColor}, TextComponent, + color::{Color, NamedColor}, }, }; use crate::{ command::{ + CommandError, CommandExecutor, CommandSender, args::{ - bounded_num::BoundedNumArgumentConsumer, position_2d::Position2DArgumentConsumer, ConsumedArgs, DefaultNameArgConsumer, FindArgDefaultName, + bounded_num::BoundedNumArgumentConsumer, position_2d::Position2DArgumentConsumer, }, - tree::builder::{argument_default_name, literal}, tree::CommandTree, - CommandError, CommandExecutor, CommandSender, + tree::builder::{argument_default_name, literal}, }, server::Server, }; diff --git a/pumpkin/src/command/dispatcher.rs b/pumpkin/src/command/dispatcher.rs index e89522523..45795ee63 100644 --- a/pumpkin/src/command/dispatcher.rs +++ b/pumpkin/src/command/dispatcher.rs @@ -4,11 +4,11 @@ use pumpkin_util::text::TextComponent; use super::args::ConsumedArgs; +use crate::command::CommandSender; use crate::command::dispatcher::CommandError::{ GeneralCommandIssue, InvalidConsumption, InvalidRequirement, OtherPumpkin, PermissionDenied, }; use crate::command::tree::{Command, CommandTree, NodeType, RawArgs}; -use crate::command::CommandSender; use crate::error::PumpkinError; use crate::server::Server; use pumpkin_util::text::color::{Color, NamedColor}; @@ -35,11 +35,15 @@ impl CommandError { pub fn into_string_or_pumpkin_error(self, cmd: &str) -> Result> { match self { InvalidConsumption(s) => { - log::error!("Error while parsing command \"{cmd}\": {s:?} was consumed, but couldn't be parsed"); + log::error!( + "Error while parsing command \"{cmd}\": {s:?} was consumed, but couldn't be parsed" + ); Ok("Internal Error (See logs for details)".into()) } InvalidRequirement => { - log::error!("Error while parsing command \"{cmd}\": a requirement that was expected was not met."); + log::error!( + "Error while parsing command \"{cmd}\": a requirement that was expected was not met." + ); Ok("Internal Error (See logs for details)".into()) } PermissionDenied => { @@ -114,11 +118,15 @@ impl CommandDispatcher { .await { Err(InvalidConsumption(s)) => { - log::error!("Error while parsing command \"{cmd}\": {s:?} was consumed, but couldn't be parsed"); + log::error!( + "Error while parsing command \"{cmd}\": {s:?} was consumed, but couldn't be parsed" + ); return Vec::new(); } Err(InvalidRequirement) => { - log::error!("Error while parsing command \"{cmd}\": a requirement that was expected was not met."); + log::error!( + "Error while parsing command \"{cmd}\": a requirement that was expected was not met." + ); return Vec::new(); } Err(PermissionDenied) => { @@ -196,7 +204,9 @@ impl CommandDispatcher { Command::Tree(tree) => Ok(tree), Command::Alias(target) => { let Some(Command::Tree(tree)) = self.commands.get(target) else { - log::error!("Error while parsing command alias \"{key}\": pointing to \"{target}\" which is not a valid tree"); + log::error!( + "Error while parsing command alias \"{key}\": pointing to \"{target}\" which is not a valid tree" + ); return Err(GeneralCommandIssue( "Internal Error (See logs for details)".into(), )); diff --git a/pumpkin/src/command/tree/builder.rs b/pumpkin/src/command/tree/builder.rs index fe4149734..4682d60fe 100644 --- a/pumpkin/src/command/tree/builder.rs +++ b/pumpkin/src/command/tree/builder.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use super::CommandExecutor; +use crate::command::CommandSender; use crate::command::args::{ArgumentConsumer, DefaultNameArgConsumer}; use crate::command::tree::{CommandTree, Node, NodeType}; -use crate::command::CommandSender; impl CommandTree { /// Add a child [Node] to the root of this [`CommandTree`]. diff --git a/pumpkin/src/command/tree/mod.rs b/pumpkin/src/command/tree/mod.rs index e56811f47..4c47f66cb 100644 --- a/pumpkin/src/command/tree/mod.rs +++ b/pumpkin/src/command/tree/mod.rs @@ -1,4 +1,4 @@ -use super::{args::ArgumentConsumer, CommandExecutor}; +use super::{CommandExecutor, args::ArgumentConsumer}; use crate::command::CommandSender; use std::{collections::VecDeque, fmt::Debug, sync::Arc}; diff --git a/pumpkin/src/data/banned_ip_data.rs b/pumpkin/src/data/banned_ip_data.rs index f524530cc..4e7c9acd6 100644 --- a/pumpkin/src/data/banned_ip_data.rs +++ b/pumpkin/src/data/banned_ip_data.rs @@ -3,7 +3,7 @@ use std::{net::IpAddr, path::Path, sync::LazyLock}; use chrono::Local; use serde::{Deserialize, Serialize}; -use super::{banlist_serializer::BannedIpEntry, LoadJSONConfiguration, SaveJSONConfiguration}; +use super::{LoadJSONConfiguration, SaveJSONConfiguration, banlist_serializer::BannedIpEntry}; pub static BANNED_IP_LIST: LazyLock> = LazyLock::new(|| tokio::sync::RwLock::new(BannedIpList::load())); diff --git a/pumpkin/src/data/banned_player_data.rs b/pumpkin/src/data/banned_player_data.rs index ceb62cab5..b847ade58 100644 --- a/pumpkin/src/data/banned_player_data.rs +++ b/pumpkin/src/data/banned_player_data.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use crate::net::GameProfile; -use super::{banlist_serializer::BannedPlayerEntry, LoadJSONConfiguration, SaveJSONConfiguration}; +use super::{LoadJSONConfiguration, SaveJSONConfiguration, banlist_serializer::BannedPlayerEntry}; pub static BANNED_PLAYER_LIST: LazyLock> = LazyLock::new(|| tokio::sync::RwLock::new(BannedPlayerList::load())); diff --git a/pumpkin/src/data/mod.rs b/pumpkin/src/data/mod.rs index f8093426c..2a0f20c6c 100644 --- a/pumpkin/src/data/mod.rs +++ b/pumpkin/src/data/mod.rs @@ -38,7 +38,7 @@ pub trait LoadJSONConfiguration { if let Err(err) = fs::write(&path, serde_json::to_string_pretty(&content).unwrap()) { log::error!( - "Couldn't write default data config to {path:?}. Reason: {err}. This is probably caused by a config update. Just delete the old data config and restart.", + "Couldn't write default data config to {path:?}. Reason: {err}. This is probably caused by a config update. Just delete the old data config and restart.", ); } diff --git a/pumpkin/src/entity/combat.rs b/pumpkin/src/entity/combat.rs index a11401124..0bb5bcb4b 100644 --- a/pumpkin/src/entity/combat.rs +++ b/pumpkin/src/entity/combat.rs @@ -7,7 +7,7 @@ use pumpkin_util::math::vector3::Vector3; use pumpkin_world::item::ItemStack; use crate::{ - entity::{player::Player, Entity}, + entity::{Entity, player::Player}, world::World, }; @@ -50,11 +50,7 @@ impl AttackType { return Self::Sweeping; } - if is_strong { - Self::Strong - } else { - Self::Weak - } + if is_strong { Self::Strong } else { Self::Weak } } } diff --git a/pumpkin/src/entity/item.rs b/pumpkin/src/entity/item.rs index b0e9b6da8..a404264d0 100644 --- a/pumpkin/src/entity/item.rs +++ b/pumpkin/src/entity/item.rs @@ -1,6 +1,6 @@ use std::sync::{ - atomic::{AtomicI8, AtomicU8}, Arc, + atomic::{AtomicI8, AtomicU8}, }; use async_trait::async_trait; @@ -10,7 +10,7 @@ use pumpkin_protocol::{ }; use pumpkin_world::item::ItemStack; -use super::{living::LivingEntity, player::Player, Entity, EntityBase}; +use super::{Entity, EntityBase, living::LivingEntity, player::Player}; pub struct ItemEntity { entity: Entity, diff --git a/pumpkin/src/entity/mob/mod.rs b/pumpkin/src/entity/mob/mod.rs index 3b4626f15..c470253b1 100644 --- a/pumpkin/src/entity/mob/mod.rs +++ b/pumpkin/src/entity/mob/mod.rs @@ -9,9 +9,9 @@ use zombie::Zombie; use crate::{server::Server, world::World}; use super::{ + Entity, EntityBase, ai::{goal::Goal, path::Navigator}, living::LivingEntity, - Entity, EntityBase, }; pub mod zombie; @@ -62,7 +62,6 @@ pub async fn from_type( goals: Mutex::new(vec![]), navigator: Mutex::new(Navigator::default()), }; - #[expect(clippy::single_match)] match entity_type { EntityType::ZOMBIE => Zombie::make(&mob).await, // TODO diff --git a/pumpkin/src/entity/mod.rs b/pumpkin/src/entity/mod.rs index 32535a3fa..ed86115a7 100644 --- a/pumpkin/src/entity/mod.rs +++ b/pumpkin/src/entity/mod.rs @@ -1,5 +1,5 @@ use core::f32; -use std::sync::{atomic::AtomicBool, Arc}; +use std::sync::{Arc, atomic::AtomicBool}; use async_trait::async_trait; use crossbeam::atomic::AtomicCell; diff --git a/pumpkin/src/entity/player.rs b/pumpkin/src/entity/player.rs index 975d28fab..db47e40e3 100644 --- a/pumpkin/src/entity/player.rs +++ b/pumpkin/src/entity/player.rs @@ -2,8 +2,8 @@ use pumpkin_world::block::registry::State; use std::{ num::NonZeroU8, sync::{ - atomic::{AtomicBool, AtomicI32, AtomicI64, AtomicU32, Ordering}, Arc, + atomic::{AtomicBool, AtomicI32, AtomicI64, AtomicU32, Ordering}, }, time::{Duration, Instant}, }; @@ -21,6 +21,7 @@ use pumpkin_data::{ use pumpkin_inventory::player::PlayerInventory; use pumpkin_nbt::compound::NbtCompound; use pumpkin_protocol::{ + RawPacket, ServerPacket, bytebuf::packet::Packet, client::play::{ CAcknowledgeBlockChange, CActionBar, CCombatDeath, CDisguisedChatMessage, CEntityStatus, @@ -35,7 +36,6 @@ use pumpkin_protocol::{ SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSetPlayerGround, SSwingArm, SUpdateSign, SUseItem, SUseItemOn, }, - RawPacket, ServerPacket, }; use pumpkin_protocol::{ client::play::CSoundEffect, @@ -49,6 +49,7 @@ use pumpkin_protocol::{ server::play::{SClickContainer, SKeepAlive}, }; use pumpkin_util::{ + GameMode, math::{ boundingbox::{BoundingBox, EntityDimensions}, experience, @@ -58,16 +59,15 @@ use pumpkin_util::{ }, permission::PermissionLvl, text::TextComponent, - GameMode, }; use pumpkin_world::{cylindrical_chunk_iterator::Cylindrical, item::ItemStack}; use tokio::sync::{Mutex, Notify, RwLock}; use super::{ - combat::{self, player_attack_sound, AttackType}, + Entity, EntityBase, EntityId, NBTStorage, + combat::{self, AttackType, player_attack_sound}, hunger::HungerManager, item::ItemEntity, - Entity, EntityBase, EntityId, NBTStorage, }; use crate::{ block, diff --git a/pumpkin/src/entity/projectile/mod.rs b/pumpkin/src/entity/projectile/mod.rs index a316b49a5..bc05dbb77 100644 --- a/pumpkin/src/entity/projectile/mod.rs +++ b/pumpkin/src/entity/projectile/mod.rs @@ -2,7 +2,7 @@ use std::f32::{self}; use pumpkin_util::math::vector3::Vector3; -use super::{living::LivingEntity, Entity, EntityBase}; +use super::{Entity, EntityBase, living::LivingEntity}; pub struct ThrownItemEntity { entity: Entity, diff --git a/pumpkin/src/lib.rs b/pumpkin/src/lib.rs index 758a0eb3e..cf11b195d 100644 --- a/pumpkin/src/lib.rs +++ b/pumpkin/src/lib.rs @@ -1,9 +1,9 @@ // Not warn event sending macros #![allow(unused_labels)] -use crate::net::{lan_broadcast, query, rcon::RCONServer, Client}; -use crate::server::{ticker::Ticker, Server}; -use log::{logger, Level, LevelFilter, Log}; +use crate::net::{Client, lan_broadcast, query, rcon::RCONServer}; +use crate::server::{Server, ticker::Ticker}; +use log::{Level, LevelFilter, Log, logger}; use net::PacketHandlerState; use plugin::PluginManager; use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG}; @@ -11,8 +11,8 @@ use pumpkin_util::text::TextComponent; use rustyline_async::{Readline, ReadlineEvent}; use std::collections::HashMap; use std::str::FromStr; -use std::sync::atomic::AtomicBool; use std::sync::OnceLock; +use std::sync::atomic::AtomicBool; use std::{ net::SocketAddr, sync::{Arc, LazyLock}, @@ -22,7 +22,7 @@ use tokio::sync::Notify; use tokio::task::JoinHandle; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, - net::{tcp::OwnedReadHalf, TcpListener}, + net::{TcpListener, tcp::OwnedReadHalf}, sync::Mutex, }; diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index e302bc749..ed4f34fbe 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -44,13 +44,13 @@ use std::{ #[cfg(not(unix))] use tokio::signal::ctrl_c; #[cfg(unix)] -use tokio::signal::unix::{signal, SignalKind}; +use tokio::signal::unix::{SignalKind, signal}; use tokio::sync::Mutex; use crate::server::CURRENT_MC_VERSION; -use pumpkin::{init_log, stop_server, PumpkinServer, SHOULD_STOP}; +use pumpkin::{PumpkinServer, SHOULD_STOP, init_log, stop_server}; use pumpkin_protocol::CURRENT_MC_PROTOCOL; -use pumpkin_util::text::{color::NamedColor, TextComponent}; +use pumpkin_util::text::{TextComponent, color::NamedColor}; use std::time::Instant; // Setup some tokens to allow us to identify which event is for which socket. @@ -88,7 +88,9 @@ async fn main() { std::process::exit(1); })); - log::info!("Starting Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION}) for Minecraft {CURRENT_MC_VERSION} (Protocol {CURRENT_MC_PROTOCOL})",); + log::info!( + "Starting Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION}) for Minecraft {CURRENT_MC_VERSION} (Protocol {CURRENT_MC_PROTOCOL})", + ); log::debug!( "Build info: FAMILY: \"{}\", OS: \"{}\", ARCH: \"{}\", BUILD: \"{}\"", diff --git a/pumpkin/src/net/authentication.rs b/pumpkin/src/net/authentication.rs index ba871c9c1..7623d2019 100644 --- a/pumpkin/src/net/authentication.rs +++ b/pumpkin/src/net/authentication.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, net::IpAddr}; -use base64::{engine::general_purpose, Engine}; -use pumpkin_config::{networking::auth::TextureConfig, ADVANCED_CONFIG}; +use base64::{Engine, engine::general_purpose}; +use pumpkin_config::{ADVANCED_CONFIG, networking::auth::TextureConfig}; use pumpkin_protocol::Property; use reqwest::{StatusCode, Url}; use serde::Deserialize; diff --git a/pumpkin/src/net/container.rs b/pumpkin/src/net/container.rs index 2746642e4..9a2498fba 100644 --- a/pumpkin/src/net/container.rs +++ b/pumpkin/src/net/container.rs @@ -2,21 +2,21 @@ use crate::entity::player::Player; use crate::server::Server; use pumpkin_data::item::Item; use pumpkin_data::screen::WindowType; +use pumpkin_inventory::Container; use pumpkin_inventory::container_click::{ Click, ClickType, KeyClick, MouseClick, MouseDragState, MouseDragType, }; use pumpkin_inventory::drag_handler::DragHandler; use pumpkin_inventory::window_property::{WindowProperty, WindowPropertyTrait}; -use pumpkin_inventory::Container; -use pumpkin_inventory::{container_click, InventoryError, OptionallyCombinedContainer}; +use pumpkin_inventory::{InventoryError, OptionallyCombinedContainer, container_click}; use pumpkin_protocol::client::play::{ CCloseContainer, COpenScreen, CSetContainerContent, CSetContainerProperty, CSetContainerSlot, }; use pumpkin_protocol::codec::slot::Slot; use pumpkin_protocol::codec::var_int::VarInt; use pumpkin_protocol::server::play::SClickContainer; -use pumpkin_util::text::TextComponent; use pumpkin_util::GameMode; +use pumpkin_util::text::TextComponent; use pumpkin_world::item::ItemStack; use std::sync::Arc; diff --git a/pumpkin/src/net/lan_broadcast.rs b/pumpkin/src/net/lan_broadcast.rs index 187fd4313..9f02635f8 100644 --- a/pumpkin/src/net/lan_broadcast.rs +++ b/pumpkin/src/net/lan_broadcast.rs @@ -30,7 +30,9 @@ pub async fn start_lan_broadcast(bound_addr: SocketAddr) { if advanced_motd.is_empty() { motd = BASIC_CONFIG.motd.replace('\n', " "); - log::warn!("Using the server MOTD as the LAN broadcast MOTD. Note that the LAN broadcast MOTD does not support multiple lines, RGB colors, or gradients so consider defining it accordingly."); + log::warn!( + "Using the server MOTD as the LAN broadcast MOTD. Note that the LAN broadcast MOTD does not support multiple lines, RGB colors, or gradients so consider defining it accordingly." + ); } else { motd = advanced_motd.clone(); }; diff --git a/pumpkin/src/net/mod.rs b/pumpkin/src/net/mod.rs index 2c03f389e..2438a02c4 100644 --- a/pumpkin/src/net/mod.rs +++ b/pumpkin/src/net/mod.rs @@ -3,8 +3,8 @@ use std::{ net::SocketAddr, num::NonZeroU8, sync::{ - atomic::{AtomicBool, AtomicI32}, Arc, + atomic::{AtomicBool, AtomicI32}, }, }; @@ -17,7 +17,9 @@ use crate::{ use crossbeam::atomic::AtomicCell; use pumpkin_config::networking::compression::CompressionInfo; use pumpkin_protocol::{ - bytebuf::{packet::Packet, ReadingError}, + ClientPacket, CompressionLevel, CompressionThreshold, ConnectionState, Property, RawPacket, + ServerPacket, + bytebuf::{ReadingError, packet::Packet}, client::{config::CConfigDisconnect, login::CLoginDisconnect, play::CPlayDisconnect}, packet_decoder::PacketDecoder, packet_encoder::{PacketEncodeError, PacketEncoder}, @@ -33,15 +35,13 @@ use pumpkin_protocol::{ }, status::{SStatusPingRequest, SStatusRequest}, }, - ClientPacket, CompressionLevel, CompressionThreshold, ConnectionState, Property, RawPacket, - ServerPacket, }; -use pumpkin_util::{text::TextComponent, ProfileAction}; +use pumpkin_util::{ProfileAction, text::TextComponent}; use serde::Deserialize; use sha1::Digest; use sha2::Sha256; -use tokio::sync::mpsc; use tokio::sync::Mutex; +use tokio::sync::mpsc; use thiserror::Error; use uuid::Uuid; diff --git a/pumpkin/src/net/packet/config.rs b/pumpkin/src/net/packet/config.rs index 4e1817aa5..0ca05779a 100644 --- a/pumpkin/src/net/packet/config.rs +++ b/pumpkin/src/net/packet/config.rs @@ -7,12 +7,12 @@ use crate::{ }; use core::str; use pumpkin_protocol::{ + ConnectionState, client::config::{CFinishConfig, CRegistryData}, codec::var_int::VarInt, server::config::{ SClientInformationConfig, SConfigCookieResponse, SKnownPacks, SPluginMessage, }, - ConnectionState, }; use pumpkin_util::text::TextComponent; diff --git a/pumpkin/src/net/packet/handshake.rs b/pumpkin/src/net/packet/handshake.rs index a49a4ed55..c3d56d0dc 100644 --- a/pumpkin/src/net/packet/handshake.rs +++ b/pumpkin/src/net/packet/handshake.rs @@ -1,6 +1,6 @@ use std::num::NonZeroI32; -use pumpkin_protocol::{server::handshake::SHandShake, ConnectionState, CURRENT_MC_PROTOCOL}; +use pumpkin_protocol::{CURRENT_MC_PROTOCOL, ConnectionState, server::handshake::SHandShake}; use pumpkin_util::text::TextComponent; use crate::{net::Client, server::CURRENT_MC_VERSION}; diff --git a/pumpkin/src/net/packet/login.rs b/pumpkin/src/net/packet/login.rs index 511a8e9c0..16a555c50 100644 --- a/pumpkin/src/net/packet/login.rs +++ b/pumpkin/src/net/packet/login.rs @@ -2,24 +2,24 @@ use std::sync::LazyLock; use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG}; use pumpkin_protocol::{ + ConnectionState, KnownPack, Label, Link, LinkType, client::{ config::{CConfigAddResourcePack, CConfigServerLinks, CKnownPacks, CUpdateTags}, login::{CLoginSuccess, CSetCompression}, }, codec::var_int::VarInt, server::login::{SEncryptionResponse, SLoginCookieResponse, SLoginPluginResponse, SLoginStart}, - ConnectionState, KnownPack, Label, Link, LinkType, }; use pumpkin_util::text::TextComponent; use uuid::Uuid; use crate::{ net::{ + Client, GameProfile, authentication::{self, AuthError}, offline_uuid, packet::is_valid_player_name, proxy::{bungeecord, velocity}, - Client, GameProfile, }, server::Server, }; @@ -205,7 +205,14 @@ impl Client { // Don't allow duplicate UUIDs if let Some(online_player) = &server.get_player_by_uuid(profile.id).await { - log::debug!("Player (IP '{}', username '{}') tried to log in with the same UUID ('{}') as an online player (IP '{}', username '{}')", &self.address.lock().await, &profile.name, &profile.id, &online_player.client.address.lock().await, &online_player.gameprofile.name); + log::debug!( + "Player (IP '{}', username '{}') tried to log in with the same UUID ('{}') as an online player (IP '{}', username '{}')", + &self.address.lock().await, + &profile.name, + &profile.id, + &online_player.client.address.lock().await, + &online_player.gameprofile.name + ); self.kick(&TextComponent::translate( "multiplayer.disconnect.duplicate_login", [], @@ -216,7 +223,14 @@ impl Client { // Don't allow a duplicate username if let Some(online_player) = &server.get_player_by_name(&profile.name).await { - log::debug!("A player (IP '{}', attempted username '{}') tried to log in with the same username as an online player (UUID '{}', IP '{}', username '{}')", &self.address.lock().await, &profile.name, &profile.id, &online_player.client.address.lock().await, &online_player.gameprofile.name); + log::debug!( + "A player (IP '{}', attempted username '{}') tried to log in with the same username as an online player (UUID '{}', IP '{}', username '{}')", + &self.address.lock().await, + &profile.name, + &profile.id, + &online_player.client.address.lock().await, + &online_player.gameprofile.name + ); self.kick(&TextComponent::translate( "multiplayer.disconnect.duplicate_login", [], @@ -295,11 +309,11 @@ impl Client { pub fn handle_login_cookie_response(&self, packet: SLoginCookieResponse) { // TODO: allow plugins to access this log::debug!( - "Received cookie_response[login]: key: \"{}\", has_payload: \"{}\", payload_length: \"{}\"", - packet.key.to_string(), - packet.has_payload, - packet.payload_length.unwrap_or(VarInt::from(0)).0 - ); + "Received cookie_response[login]: key: \"{}\", has_payload: \"{}\", payload_length: \"{}\"", + packet.key.to_string(), + packet.has_payload, + packet.payload_length.unwrap_or(VarInt::from(0)).0 + ); } pub async fn handle_plugin_response(&self, plugin_response: SLoginPluginResponse) { log::debug!("Handling plugin"); diff --git a/pumpkin/src/net/packet/play.rs b/pumpkin/src/net/packet/play.rs index eb38f9b9a..eaa11ffe7 100644 --- a/pumpkin/src/net/packet/play.rs +++ b/pumpkin/src/net/packet/play.rs @@ -14,13 +14,13 @@ use crate::{ world::chunker, }; use pumpkin_config::ADVANCED_CONFIG; -use pumpkin_data::entity::{entity_from_egg, EntityType}; +use pumpkin_data::entity::{EntityType, entity_from_egg}; use pumpkin_data::item::Item; use pumpkin_data::sound::Sound; use pumpkin_data::sound::SoundCategory; use pumpkin_data::world::CHAT; -use pumpkin_inventory::player::PlayerInventory; use pumpkin_inventory::InventoryError; +use pumpkin_inventory::player::PlayerInventory; use pumpkin_macros::block_entity; use pumpkin_protocol::client::play::{ CBlockEntityData, COpenSignEditor, CSetContainerSlot, CSetHeldItem, EquipmentSlot, @@ -45,14 +45,14 @@ use pumpkin_util::math::boundingbox::BoundingBox; use pumpkin_util::math::position::BlockPos; use pumpkin_util::text::color::NamedColor; use pumpkin_util::{ + GameMode, math::{vector3::Vector3, wrap_degrees}, text::TextComponent, - GameMode, }; use pumpkin_world::block::interactive::sign::Sign; -use pumpkin_world::block::registry::get_block_collision_shapes; use pumpkin_world::block::registry::Block; -use pumpkin_world::block::{registry::get_block_by_item, BlockDirection}; +use pumpkin_world::block::registry::get_block_collision_shapes; +use pumpkin_world::block::{BlockDirection, registry::get_block_by_item}; use pumpkin_world::item::ItemStack; use pumpkin_world::{WORLD_LOWEST_Y, WORLD_MAX_Y}; diff --git a/pumpkin/src/net/proxy/bungeecord.rs b/pumpkin/src/net/proxy/bungeecord.rs index dc1976713..4fc0580ed 100644 --- a/pumpkin/src/net/proxy/bungeecord.rs +++ b/pumpkin/src/net/proxy/bungeecord.rs @@ -4,7 +4,7 @@ use pumpkin_protocol::Property; use thiserror::Error; use tokio::sync::Mutex; -use crate::net::{offline_uuid, GameProfile}; +use crate::net::{GameProfile, offline_uuid}; #[derive(Error, Debug)] pub enum BungeeCordError { diff --git a/pumpkin/src/net/proxy/velocity.rs b/pumpkin/src/net/proxy/velocity.rs index 4394e1feb..0a0c2461c 100644 --- a/pumpkin/src/net/proxy/velocity.rs +++ b/pumpkin/src/net/proxy/velocity.rs @@ -7,8 +7,8 @@ use bytes::{BufMut, BytesMut}; use hmac::{Hmac, Mac}; use pumpkin_config::networking::proxy::VelocityConfig; use pumpkin_protocol::{ - bytebuf::ByteBuf, client::login::CLoginPluginRequest, server::login::SLoginPluginResponse, - Property, + Property, bytebuf::ByteBuf, client::login::CLoginPluginRequest, + server::login::SLoginPluginResponse, }; use rand::Rng; use sha2::Sha256; @@ -45,7 +45,7 @@ pub enum VelocityError { pub async fn velocity_login(client: &Client) { // TODO: validate packet transaction id from plugin response with this - let velocity_message_id: i32 = rand::thread_rng().gen(); + let velocity_message_id: i32 = rand::thread_rng().r#gen(); let mut buf = BytesMut::new(); buf.put_u8(MAX_SUPPORTED_FORWARDING_VERSION); diff --git a/pumpkin/src/net/query.rs b/pumpkin/src/net/query.rs index 1265135c0..f44a58570 100644 --- a/pumpkin/src/net/query.rs +++ b/pumpkin/src/net/query.rs @@ -13,7 +13,7 @@ use pumpkin_protocol::query::{ use rand::Rng; use tokio::{net::UdpSocket, sync::RwLock, time}; -use crate::server::{Server, CURRENT_MC_VERSION}; +use crate::server::{CURRENT_MC_VERSION, Server}; pub async fn start_query_handler(server: Arc, bound_addr: SocketAddr) { let mut query_addr = bound_addr; diff --git a/pumpkin/src/net/rcon/mod.rs b/pumpkin/src/net/rcon/mod.rs index a4f806216..c89d2bd8e 100644 --- a/pumpkin/src/net/rcon/mod.rs +++ b/pumpkin/src/net/rcon/mod.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use packet::{ClientboundPacket, Packet, PacketError, ServerboundPacket}; -use pumpkin_config::{RCONConfig, ADVANCED_CONFIG}; +use pumpkin_config::{ADVANCED_CONFIG, RCONConfig}; use std::sync::Arc; use tokio::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/pumpkin/src/plugin/api/events/block/block_break.rs b/pumpkin/src/plugin/api/events/block/block_break.rs index fbbc63958..b1b3baec5 100644 --- a/pumpkin/src/plugin/api/events/block/block_break.rs +++ b/pumpkin/src/plugin/api/events/block/block_break.rs @@ -1,4 +1,4 @@ -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::block::registry::Block; use std::sync::Arc; diff --git a/pumpkin/src/plugin/api/events/block/block_burn.rs b/pumpkin/src/plugin/api/events/block/block_burn.rs index eb73bb1b9..be053afcc 100644 --- a/pumpkin/src/plugin/api/events/block/block_burn.rs +++ b/pumpkin/src/plugin/api/events/block/block_burn.rs @@ -1,4 +1,4 @@ -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::block::registry::Block; use super::BlockEvent; diff --git a/pumpkin/src/plugin/api/events/block/block_can_build.rs b/pumpkin/src/plugin/api/events/block/block_can_build.rs index 798dc920c..0d3a28ac7 100644 --- a/pumpkin/src/plugin/api/events/block/block_can_build.rs +++ b/pumpkin/src/plugin/api/events/block/block_can_build.rs @@ -1,4 +1,4 @@ -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::block::registry::Block; use std::sync::Arc; diff --git a/pumpkin/src/plugin/api/events/block/block_place.rs b/pumpkin/src/plugin/api/events/block/block_place.rs index a750b4be4..39450bfae 100644 --- a/pumpkin/src/plugin/api/events/block/block_place.rs +++ b/pumpkin/src/plugin/api/events/block/block_place.rs @@ -1,4 +1,4 @@ -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::block::registry::Block; use std::sync::Arc; diff --git a/pumpkin/src/plugin/api/events/player/player_join.rs b/pumpkin/src/plugin/api/events/player/player_join.rs index 79a877701..bcee2365a 100644 --- a/pumpkin/src/plugin/api/events/player/player_join.rs +++ b/pumpkin/src/plugin/api/events/player/player_join.rs @@ -1,4 +1,4 @@ -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_util::text::TextComponent; use std::sync::Arc; diff --git a/pumpkin/src/plugin/api/events/player/player_leave.rs b/pumpkin/src/plugin/api/events/player/player_leave.rs index 5e7126479..c66683fd9 100644 --- a/pumpkin/src/plugin/api/events/player/player_leave.rs +++ b/pumpkin/src/plugin/api/events/player/player_leave.rs @@ -1,4 +1,4 @@ -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_util::text::TextComponent; use std::sync::Arc; diff --git a/pumpkin/src/plugin/api/events/world/chunk_load.rs b/pumpkin/src/plugin/api/events/world/chunk_load.rs index fdfc3a123..5bbbc0433 100644 --- a/pumpkin/src/plugin/api/events/world/chunk_load.rs +++ b/pumpkin/src/plugin/api/events/world/chunk_load.rs @@ -1,5 +1,5 @@ use crate::world::World; -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::chunk::ChunkData; use std::sync::Arc; use tokio::sync::RwLock; diff --git a/pumpkin/src/plugin/api/events/world/chunk_save.rs b/pumpkin/src/plugin/api/events/world/chunk_save.rs index fda4b4c2c..e9fb38043 100644 --- a/pumpkin/src/plugin/api/events/world/chunk_save.rs +++ b/pumpkin/src/plugin/api/events/world/chunk_save.rs @@ -1,5 +1,5 @@ use crate::world::World; -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::chunk::ChunkData; use std::sync::Arc; use tokio::sync::RwLock; diff --git a/pumpkin/src/plugin/api/events/world/chunk_send.rs b/pumpkin/src/plugin/api/events/world/chunk_send.rs index 02645a098..601ceaaae 100644 --- a/pumpkin/src/plugin/api/events/world/chunk_send.rs +++ b/pumpkin/src/plugin/api/events/world/chunk_send.rs @@ -1,5 +1,5 @@ use crate::world::World; -use pumpkin_macros::{cancellable, Event}; +use pumpkin_macros::{Event, cancellable}; use pumpkin_world::chunk::ChunkData; use std::sync::Arc; use tokio::sync::RwLock; diff --git a/pumpkin/src/server/connection_cache.rs b/pumpkin/src/server/connection_cache.rs index e9bac06bf..11977e412 100644 --- a/pumpkin/src/server/connection_cache.rs +++ b/pumpkin/src/server/connection_cache.rs @@ -6,12 +6,12 @@ use std::{ path::Path, }; -use base64::{engine::general_purpose, Engine as _}; -use pumpkin_config::{BasicConfiguration, BASIC_CONFIG}; +use base64::{Engine as _, engine::general_purpose}; +use pumpkin_config::{BASIC_CONFIG, BasicConfiguration}; use pumpkin_protocol::{ + CURRENT_MC_PROTOCOL, Players, StatusResponse, Version, client::{config::CPluginMessage, status::CStatusResponse}, - codec::{var_int::VarInt, Codec}, - Players, StatusResponse, Version, CURRENT_MC_PROTOCOL, + codec::{Codec, var_int::VarInt}, }; use super::CURRENT_MC_VERSION; diff --git a/pumpkin/src/server/key_store.rs b/pumpkin/src/server/key_store.rs index 84d2c0d84..070eb7e1b 100644 --- a/pumpkin/src/server/key_store.rs +++ b/pumpkin/src/server/key_store.rs @@ -1,7 +1,7 @@ use num_bigint::BigInt; use pumpkin_protocol::client::login::CEncryptionRequest; use rand::rngs::OsRng; -use rsa::{traits::PublicKeyParts as _, Pkcs1v15Encrypt, RsaPrivateKey}; +use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, traits::PublicKeyParts as _}; use sha1::Sha1; use sha2::Digest; diff --git a/pumpkin/src/server/mod.rs b/pumpkin/src/server/mod.rs index e22b2163b..d529435a9 100644 --- a/pumpkin/src/server/mod.rs +++ b/pumpkin/src/server/mod.rs @@ -6,7 +6,7 @@ use pumpkin_data::entity::EntityType; use pumpkin_inventory::drag_handler::DragHandler; use pumpkin_inventory::{Container, OpenContainer}; use pumpkin_protocol::client::login::CEncryptionRequest; -use pumpkin_protocol::{client::config::CPluginMessage, ClientPacket}; +use pumpkin_protocol::{ClientPacket, client::config::CPluginMessage}; use pumpkin_registry::{DimensionType, Registry}; use pumpkin_util::math::boundingbox::{BoundingBox, EntityDimensions}; use pumpkin_util::math::position::BlockPos; @@ -21,8 +21,8 @@ use std::net::IpAddr; use std::sync::atomic::AtomicU32; use std::{ sync::{ - atomic::{AtomicI32, Ordering}, Arc, + atomic::{AtomicI32, Ordering}, }, time::Duration, }; diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index ea652ef4c..245a3bc4d 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -1,15 +1,15 @@ use std::{ collections::HashMap, - sync::{atomic::Ordering, Arc}, + sync::{Arc, atomic::Ordering}, }; pub mod chunker; pub mod time; use crate::{ - block, + PLUGIN_MANAGER, block, command::client_suggestions, - entity::{player::Player, Entity, EntityBase, EntityId}, + entity::{Entity, EntityBase, EntityId, player::Player}, error::PumpkinError, plugin::{ block::block_break::BlockBreakEvent, @@ -17,7 +17,6 @@ use crate::{ world::{chunk_load::ChunkLoad, chunk_save::ChunkSave, chunk_send::ChunkSend}, }, server::Server, - PLUGIN_MANAGER, }; use border::Worldborder; use pumpkin_config::BasicConfiguration; @@ -31,18 +30,18 @@ use pumpkin_macros::send_cancellable; use pumpkin_protocol::client::play::{ CBlockUpdate, CDisguisedChatMessage, CRespawn, CSetBlockDestroyStage, CWorldEvent, }; -use pumpkin_protocol::{client::play::CLevelEvent, codec::identifier::Identifier}; use pumpkin_protocol::{ + ClientPacket, client::play::{ CChunkData, CGameEvent, CLogin, CPlayerInfoUpdate, CRemoveEntities, CRemovePlayerInfo, CSpawnEntity, GameEvent, PlayerAction, }, - ClientPacket, }; +use pumpkin_protocol::{client::play::CLevelEvent, codec::identifier::Identifier}; use pumpkin_registry::DimensionType; use pumpkin_util::math::vector2::Vector2; use pumpkin_util::math::{position::BlockPos, vector3::Vector3}; -use pumpkin_util::text::{color::NamedColor, TextComponent}; +use pumpkin_util::text::{TextComponent, color::NamedColor}; use pumpkin_world::chunk::ChunkData; use pumpkin_world::level::Level; use pumpkin_world::{ @@ -51,14 +50,14 @@ use pumpkin_world::{ }, coordinates::ChunkRelativeBlockCoordinates, }; -use rand::{thread_rng, Rng}; +use rand::{Rng, thread_rng}; use scoreboard::Scoreboard; use thiserror::Error; use time::LevelTime; -use tokio::sync::{mpsc::Receiver, Mutex}; +use tokio::sync::{Mutex, mpsc::Receiver}; use tokio::{ runtime::Handle, - sync::{mpsc, RwLock}, + sync::{RwLock, mpsc}, }; pub mod border; @@ -219,7 +218,7 @@ impl World { volume: f32, pitch: f32, ) { - let seed = thread_rng().gen::(); + let seed = thread_rng().r#gen::(); let players = self.players.read().await; for (_, player) in players.iter() { player diff --git a/pumpkin/src/world/scoreboard.rs b/pumpkin/src/world/scoreboard.rs index 45c17e6bb..95db81dd3 100644 --- a/pumpkin/src/world/scoreboard.rs +++ b/pumpkin/src/world/scoreboard.rs @@ -2,9 +2,9 @@ use std::collections::HashMap; use pumpkin_data::scoreboard::ScoreboardDisplaySlot; use pumpkin_protocol::{ + NumberFormat, client::play::{CDisplayObjective, CUpdateObjectives, CUpdateScore, RenderType}, codec::var_int::VarInt, - NumberFormat, }; use pumpkin_util::text::TextComponent;