Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Oct 19, 2024
1 parent 75e7b0a commit 59d75d9
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 67 deletions.
8 changes: 1 addition & 7 deletions docs/troubleshooting/common_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 3 additions & 1 deletion pumpkin/src/client/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -450,7 +452,7 @@ impl Player {
slot_index,
&slot,
);
player.client.send_packet(&packet);
player.client.send_packet(&packet).await;
}
Ok(())
}
Expand Down
8 changes: 3 additions & 5 deletions pumpkin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 10 additions & 8 deletions pumpkin/src/client/player_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -227,13 +227,15 @@ impl Player {
.await;
}

pub fn handle_chat_command(self: &Arc<Self>, server: &Server, command: SChatCommand) {
pub async fn handle_chat_command(self: &Arc<Self>, 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 /{}",
Expand Down
2 changes: 2 additions & 0 deletions pumpkin/src/commands/cmd_echest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
25 changes: 12 additions & 13 deletions pumpkin/src/commands/cmd_gamemode.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pumpkin/src/commands/cmd_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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", "?"];

Expand Down Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions pumpkin/src/commands/cmd_kick.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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(())
}),
Expand Down
11 changes: 6 additions & 5 deletions pumpkin/src/commands/cmd_kill.rs
Original file line number Diff line number Diff line change
@@ -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(())
}),
Expand Down
7 changes: 3 additions & 4 deletions pumpkin/src/commands/cmd_pumpkin.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
9 changes: 3 additions & 6 deletions pumpkin/src/commands/cmd_stop.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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)
}),
)
Expand Down
1 change: 1 addition & 0 deletions pumpkin/src/commands/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum Command<'a> {
Alias(&'a str),
}

#[expect(unused)]
pub struct CommandTree<'a> {
pub(crate) nodes: Vec<Node<'a>>,
pub(crate) children: Vec<usize>,
Expand Down
3 changes: 2 additions & 1 deletion pumpkin/src/entity/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
12 changes: 7 additions & 5 deletions pumpkin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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;
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions pumpkin/src/world/player_chunker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -46,7 +46,7 @@ pub async fn player_join(world: &World, player: Arc<Player>) {
|chunk_pos| {
loading_chunks.push(chunk_pos);
},
|chunk_pos| {
|_| {
// player
// .client
// .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z));
Expand All @@ -60,7 +60,8 @@ pub async fn player_join(world: &World, player: Arc<Player>) {
}
}

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 {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 59d75d9

Please sign in to comment.