From 59d75d9f1e27e6bf682260f9a7cd1ecef11e4b15 Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Sat, 19 Oct 2024 18:27:04 +0200 Subject: [PATCH] fix: clippy --- docs/troubleshooting/common_issues.md | 8 +------- pumpkin/src/client/container.rs | 4 +++- pumpkin/src/client/mod.rs | 8 +++----- pumpkin/src/client/player_packet.rs | 18 ++++++++++-------- pumpkin/src/commands/cmd_echest.rs | 2 ++ pumpkin/src/commands/cmd_gamemode.rs | 25 ++++++++++++------------- pumpkin/src/commands/cmd_help.rs | 3 ++- pumpkin/src/commands/cmd_kick.rs | 12 ++++++------ pumpkin/src/commands/cmd_kill.rs | 11 ++++++----- pumpkin/src/commands/cmd_pumpkin.rs | 7 +++---- pumpkin/src/commands/cmd_stop.rs | 9 +++------ pumpkin/src/commands/tree.rs | 1 + pumpkin/src/entity/player.rs | 3 ++- pumpkin/src/main.rs | 12 +++++++----- pumpkin/src/world/mod.rs | 2 +- pumpkin/src/world/player_chunker.rs | 9 +++++---- 16 files changed, 67 insertions(+), 67 deletions(-) diff --git a/docs/troubleshooting/common_issues.md b/docs/troubleshooting/common_issues.md index 98786f7f..13815323 100644 --- a/docs/troubleshooting/common_issues.md +++ b/docs/troubleshooting/common_issues.md @@ -18,13 +18,7 @@ **Cause:** The server is currently not calculating hit boxes for blocks, we're working on that. -3. ### The Server is unresponsive - - **Issue:** You have to wait before reconnecting or can't do basic things while chunks are loading. - - **Cause:** The server has currently blocking issues, we're working on that. - -4. ### Failed to verify username +3. ### Failed to verify username **Issue:** Some players reported having issues logging into the Server, including a "Failed to verify username" error. diff --git a/pumpkin/src/client/container.rs b/pumpkin/src/client/container.rs index a999231a..ac9b7247 100644 --- a/pumpkin/src/client/container.rs +++ b/pumpkin/src/client/container.rs @@ -18,6 +18,8 @@ use pumpkin_protocol::slot::Slot; use pumpkin_world::item::ItemStack; use std::sync::Arc; +#[expect(unused)] + impl Player { pub async fn open_container(&self, server: &Server, minecraft_menu_id: &str) { let inventory = self.inventory.lock().await; @@ -450,7 +452,7 @@ impl Player { slot_index, &slot, ); - player.client.send_packet(&packet); + player.client.send_packet(&packet).await; } Ok(()) } diff --git a/pumpkin/src/client/mod.rs b/pumpkin/src/client/mod.rs index bc490ea0..6d247618 100644 --- a/pumpkin/src/client/mod.rs +++ b/pumpkin/src/client/mod.rs @@ -385,11 +385,9 @@ impl Client { pub async fn poll(&self) { loop { let mut dec = self.dec.lock().await; - if let Ok(packet) = dec.decode() { - if let Some(packet) = packet { - self.add_packet(packet).await; - return; - } + if let Ok(Some(packet)) = dec.decode() { + self.add_packet(packet).await; + return; }; dec.reserve(4096); diff --git a/pumpkin/src/client/player_packet.rs b/pumpkin/src/client/player_packet.rs index c300a135..c7b9e5a9 100644 --- a/pumpkin/src/client/player_packet.rs +++ b/pumpkin/src/client/player_packet.rs @@ -117,7 +117,7 @@ impl Player { ), ) .await; - player_chunker::update_position(entity, self).await; + player_chunker::update_position(self).await; } pub async fn handle_position_rotation(&self, position_rotation: SPlayerPositionRotation) { @@ -193,7 +193,7 @@ impl Player { &CHeadRot::new(entity_id.into(), yaw as u8), ) .await; - player_chunker::update_position(entity, self).await; + player_chunker::update_position(self).await; } pub async fn handle_rotation(&self, rotation: SPlayerRotation) { @@ -227,13 +227,15 @@ impl Player { .await; } - pub fn handle_chat_command(self: &Arc, server: &Server, command: SChatCommand) { + pub async fn handle_chat_command(self: &Arc, server: &Server, command: SChatCommand) { let dispatcher = server.command_dispatcher.clone(); - dispatcher.handle_command( - &mut CommandSender::Player(self.clone()), - server, - &command.command, - ); + dispatcher + .handle_command( + &mut CommandSender::Player(self.clone()), + server, + &command.command, + ) + .await; if ADVANCED_CONFIG.commands.log_console { log::info!( "Player ({}): executed command /{}", diff --git a/pumpkin/src/commands/cmd_echest.rs b/pumpkin/src/commands/cmd_echest.rs index 0c6b0f77..a279e908 100644 --- a/pumpkin/src/commands/cmd_echest.rs +++ b/pumpkin/src/commands/cmd_echest.rs @@ -5,6 +5,8 @@ const NAMES: [&str; 2] = ["echest", "enderchest"]; const DESCRIPTION: &str = "Show your personal enderchest (this command is used for testing container behaviour)"; +#[allow(unused_variables)] + pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, server, _| { if let Some(player) = sender.as_mut_player() { diff --git a/pumpkin/src/commands/cmd_gamemode.rs b/pumpkin/src/commands/cmd_gamemode.rs index deeed543..f81a01c4 100644 --- a/pumpkin/src/commands/cmd_gamemode.rs +++ b/pumpkin/src/commands/cmd_gamemode.rs @@ -1,7 +1,6 @@ use std::str::FromStr; use num_traits::FromPrimitive; -use pumpkin_core::text::TextComponent; use pumpkin_core::GameMode; use crate::commands::arg_player::{consume_arg_player, parse_arg_player}; @@ -72,24 +71,24 @@ pub fn init_command_tree<'a>() -> CommandTree<'a> { require(&|sender| sender.is_player()).execute(&|sender, _, args| { let gamemode = parse_arg_gamemode(args)?; - return if let Player(target) = sender { + if let Player(target) = sender { if target.gamemode.load() == gamemode { - target.send_system_message(&TextComponent::text(&format!( - "You already in {:?} gamemode", - gamemode - ))); + // target.send_system_message(&TextComponent::text(&format!( + // "You already in {:?} gamemode", + // gamemode + // ))); } else { // TODO - target.set_gamemode(gamemode); - target.send_system_message(&TextComponent::text(&format!( - "Game mode was set to {:?}", - gamemode - ))); + // target.set_gamemode(gamemode); + // target.send_system_message(&TextComponent::text(&format!( + // "Game mode was set to {:?}", + // gamemode + // ))); } Ok(()) } else { Err(InvalidRequirementError) - }; + } }), ) .with_child(argument(ARG_TARGET, consume_arg_player).execute( @@ -104,7 +103,7 @@ pub fn init_command_tree<'a>() -> CommandTree<'a> { // ))); } else { // TODO - target.set_gamemode(gamemode); + // target.set_gamemode(gamemode); // sender.send_message(TextComponent::text(&format!( // "{}'s Game mode was set to {:?}", // target.gameprofile.name, gamemode diff --git a/pumpkin/src/commands/cmd_help.rs b/pumpkin/src/commands/cmd_help.rs index 9795f84d..9b6ed222 100644 --- a/pumpkin/src/commands/cmd_help.rs +++ b/pumpkin/src/commands/cmd_help.rs @@ -4,7 +4,6 @@ use crate::commands::tree::{Command, CommandTree, ConsumedArgs, RawArgs}; use crate::commands::tree_builder::argument; use crate::commands::CommandSender; use crate::server::Server; -use pumpkin_core::text::TextComponent; const NAMES: [&str; 3] = ["help", "h", "?"]; @@ -37,6 +36,8 @@ fn parse_arg_command<'a>( .map_err(|_| InvalidConsumptionError(Some(command_name.into()))) } +#[allow(unused_variables)] + pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION) .with_child( diff --git a/pumpkin/src/commands/cmd_kick.rs b/pumpkin/src/commands/cmd_kick.rs index 43a24a27..783e4516 100644 --- a/pumpkin/src/commands/cmd_kick.rs +++ b/pumpkin/src/commands/cmd_kick.rs @@ -1,7 +1,6 @@ use crate::commands::arg_player::parse_arg_player; use crate::commands::tree::CommandTree; use crate::commands::tree_builder::argument; -use pumpkin_core::text::{color::NamedColor, TextComponent}; use super::arg_player::consume_arg_player; @@ -10,16 +9,17 @@ const DESCRIPTION: &str = "Kicks the target player from the server."; const ARG_TARGET: &str = "target"; +#[expect(unused)] + pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION).with_child( argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| { - dbg!("aa"); let target = parse_arg_player(sender, server, ARG_TARGET, args)?; - target.kick(TextComponent::text("Kicked by an operator")); + // target.kick(TextComponent::text("Kicked by an operator")); - sender.send_message( - TextComponent::text("Player has been kicked.").color_named(NamedColor::Blue), - ); + // sender.send_message( + // TextComponent::text("Player has been kicked.").color_named(NamedColor::Blue), + // ); Ok(()) }), diff --git a/pumpkin/src/commands/cmd_kill.rs b/pumpkin/src/commands/cmd_kill.rs index cf420865..f820a1f8 100644 --- a/pumpkin/src/commands/cmd_kill.rs +++ b/pumpkin/src/commands/cmd_kill.rs @@ -1,23 +1,24 @@ use crate::commands::arg_player::{consume_arg_player, parse_arg_player}; use crate::commands::tree::CommandTree; use crate::commands::tree_builder::argument; -use pumpkin_core::text::{color::NamedColor, TextComponent}; const NAMES: [&str; 1] = ["kill"]; const DESCRIPTION: &str = "Kills a target player."; const ARG_TARGET: &str = "target"; +#[expect(unused)] + pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION).with_child( argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| { // TODO parse entities not only players let target = parse_arg_player(sender, server, ARG_TARGET, args)?; - target.living_entity.kill(); + // target.living_entity.kill(); - sender.send_message( - TextComponent::text("Player has been killed.").color_named(NamedColor::Blue), - ); + // sender.send_message( + // TextComponent::text("Player has been killed.").color_named(NamedColor::Blue), + // ); Ok(()) }), diff --git a/pumpkin/src/commands/cmd_pumpkin.rs b/pumpkin/src/commands/cmd_pumpkin.rs index b697e458..29d4d73c 100644 --- a/pumpkin/src/commands/cmd_pumpkin.rs +++ b/pumpkin/src/commands/cmd_pumpkin.rs @@ -1,12 +1,11 @@ -use pumpkin_core::text::{color::NamedColor, TextComponent}; -use pumpkin_protocol::CURRENT_MC_PROTOCOL; - -use crate::{commands::tree::CommandTree, server::CURRENT_MC_VERSION}; +use crate::commands::tree::CommandTree; const NAMES: [&str; 1] = ["pumpkin"]; const DESCRIPTION: &str = "Display information about Pumpkin."; +#[expect(unused)] + pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, _, _| { let version = env!("CARGO_PKG_VERSION"); diff --git a/pumpkin/src/commands/cmd_stop.rs b/pumpkin/src/commands/cmd_stop.rs index 2d90ae70..8de9c09f 100644 --- a/pumpkin/src/commands/cmd_stop.rs +++ b/pumpkin/src/commands/cmd_stop.rs @@ -1,6 +1,3 @@ -use pumpkin_core::text::color::NamedColor; -use pumpkin_core::text::TextComponent; - use crate::commands::tree::CommandTree; use crate::commands::tree_builder::require; @@ -10,9 +7,9 @@ const DESCRIPTION: &str = "Stop the server."; pub fn init_command_tree<'a>() -> CommandTree<'a> { CommandTree::new(NAMES, DESCRIPTION).with_child( - require(&|sender| sender.permission_lvl() >= 4).execute(&|sender, _, _args| { - sender - .send_message(TextComponent::text("Stopping Server").color_named(NamedColor::Red)); + require(&|sender| sender.permission_lvl() >= 4).execute(&|_sender, _, _args| { + // sender + // .send_message(TextComponent::text("Stopping Server").color_named(NamedColor::Red)); std::process::exit(0) }), ) diff --git a/pumpkin/src/commands/tree.rs b/pumpkin/src/commands/tree.rs index 65407dbc..ffadee1c 100644 --- a/pumpkin/src/commands/tree.rs +++ b/pumpkin/src/commands/tree.rs @@ -39,6 +39,7 @@ pub enum Command<'a> { Alias(&'a str), } +#[expect(unused)] pub struct CommandTree<'a> { pub(crate) nodes: Vec>, pub(crate) children: Vec, diff --git a/pumpkin/src/entity/player.rs b/pumpkin/src/entity/player.rs index 634890fc..bdb3640d 100644 --- a/pumpkin/src/entity/player.rs +++ b/pumpkin/src/entity/player.rs @@ -320,7 +320,8 @@ impl Player { Ok(()) } SChatCommand::PACKET_ID => { - self.handle_chat_command(server, SChatCommand::read(bytebuf)?); + self.handle_chat_command(server, SChatCommand::read(bytebuf)?) + .await; Ok(()) } SPlayerPosition::PACKET_ID => { diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index b1308de2..7445161e 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -88,10 +88,10 @@ async fn main() -> io::Result<()> { init_logger(); - let rt = tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap(); + // let rt = tokio::runtime::Builder::new_multi_thread() + // .enable_all() + // .build() + // .unwrap(); ctrlc::set_handler(|| { log::warn!( @@ -141,7 +141,9 @@ async fn main() -> io::Result<()> { if !out.is_empty() { let dispatcher = server.command_dispatcher.clone(); - dispatcher.handle_command(&mut commands::CommandSender::Console, &server, &out); + dispatcher + .handle_command(&mut commands::CommandSender::Console, &server, &out) + .await; } } }); diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index a4a2b76c..e68d5bfd 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -262,7 +262,7 @@ impl World { level.fetch_chunks(&chunks, sender, closed) }); - let client = client.clone(); + let client = client; tokio::spawn(async move { while let Some(chunk_data) = chunk_receiver.recv().await { // dbg!(chunk_pos); diff --git a/pumpkin/src/world/player_chunker.rs b/pumpkin/src/world/player_chunker.rs index c3d698f6..e37d5a15 100644 --- a/pumpkin/src/world/player_chunker.rs +++ b/pumpkin/src/world/player_chunker.rs @@ -7,7 +7,7 @@ use pumpkin_core::math::{ use pumpkin_protocol::client::play::CCenterChunk; use pumpkin_world::cylindrical_chunk_iterator::Cylindrical; -use crate::entity::{player::Player, Entity}; +use crate::entity::player::Player; use super::World; @@ -46,7 +46,7 @@ pub async fn player_join(world: &World, player: Arc) { |chunk_pos| { loading_chunks.push(chunk_pos); }, - |chunk_pos| { + |_| { // player // .client // .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z)); @@ -60,7 +60,8 @@ pub async fn player_join(world: &World, player: Arc) { } } -pub async fn update_position(entity: &Entity, player: &Player) { +pub async fn update_position(player: &Player) { + let entity = &player.living_entity.entity; let current_watched = player.watched_section.load(); let new_watched = chunk_section_from_pos(&entity.block_pos.load()); if current_watched != new_watched { @@ -89,7 +90,7 @@ pub async fn update_position(entity: &Entity, player: &Player) { |chunk_pos| { loading_chunks.push(chunk_pos); }, - |chunk_pos| { + |_| { // player // .client // .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z));