fix: clippy
This commit is contained in:
parent
75e7b0a8e8
commit
59d75d9f1e
@ -18,13 +18,7 @@
|
|||||||
|
|
||||||
**Cause:** The server is currently not calculating hit boxes for blocks, we're working on that.
|
**Cause:** The server is currently not calculating hit boxes for blocks, we're working on that.
|
||||||
|
|
||||||
3. ### The Server is unresponsive
|
3. ### Failed to verify username
|
||||||
|
|
||||||
**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
|
|
||||||
|
|
||||||
**Issue:** Some players reported having issues logging into the Server, including a "Failed to verify username" error.
|
**Issue:** Some players reported having issues logging into the Server, including a "Failed to verify username" error.
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,8 @@ use pumpkin_protocol::slot::Slot;
|
|||||||
use pumpkin_world::item::ItemStack;
|
use pumpkin_world::item::ItemStack;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
pub async fn open_container(&self, server: &Server, minecraft_menu_id: &str) {
|
pub async fn open_container(&self, server: &Server, minecraft_menu_id: &str) {
|
||||||
let inventory = self.inventory.lock().await;
|
let inventory = self.inventory.lock().await;
|
||||||
@ -450,7 +452,7 @@ impl Player {
|
|||||||
slot_index,
|
slot_index,
|
||||||
&slot,
|
&slot,
|
||||||
);
|
);
|
||||||
player.client.send_packet(&packet);
|
player.client.send_packet(&packet).await;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -385,11 +385,9 @@ impl Client {
|
|||||||
pub async fn poll(&self) {
|
pub async fn poll(&self) {
|
||||||
loop {
|
loop {
|
||||||
let mut dec = self.dec.lock().await;
|
let mut dec = self.dec.lock().await;
|
||||||
if let Ok(packet) = dec.decode() {
|
if let Ok(Some(packet)) = dec.decode() {
|
||||||
if let Some(packet) = packet {
|
self.add_packet(packet).await;
|
||||||
self.add_packet(packet).await;
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dec.reserve(4096);
|
dec.reserve(4096);
|
||||||
|
|||||||
@ -117,7 +117,7 @@ impl Player {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
player_chunker::update_position(entity, self).await;
|
player_chunker::update_position(self).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_position_rotation(&self, position_rotation: SPlayerPositionRotation) {
|
pub async fn handle_position_rotation(&self, position_rotation: SPlayerPositionRotation) {
|
||||||
@ -193,7 +193,7 @@ impl Player {
|
|||||||
&CHeadRot::new(entity_id.into(), yaw as u8),
|
&CHeadRot::new(entity_id.into(), yaw as u8),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
player_chunker::update_position(entity, self).await;
|
player_chunker::update_position(self).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_rotation(&self, rotation: SPlayerRotation) {
|
pub async fn handle_rotation(&self, rotation: SPlayerRotation) {
|
||||||
@ -227,13 +227,15 @@ impl Player {
|
|||||||
.await;
|
.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();
|
let dispatcher = server.command_dispatcher.clone();
|
||||||
dispatcher.handle_command(
|
dispatcher
|
||||||
&mut CommandSender::Player(self.clone()),
|
.handle_command(
|
||||||
server,
|
&mut CommandSender::Player(self.clone()),
|
||||||
&command.command,
|
server,
|
||||||
);
|
&command.command,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
if ADVANCED_CONFIG.commands.log_console {
|
if ADVANCED_CONFIG.commands.log_console {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Player ({}): executed command /{}",
|
"Player ({}): executed command /{}",
|
||||||
|
|||||||
@ -5,6 +5,8 @@ const NAMES: [&str; 2] = ["echest", "enderchest"];
|
|||||||
const DESCRIPTION: &str =
|
const DESCRIPTION: &str =
|
||||||
"Show your personal enderchest (this command is used for testing container behaviour)";
|
"Show your personal enderchest (this command is used for testing container behaviour)";
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
|
||||||
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, server, _| {
|
CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, server, _| {
|
||||||
if let Some(player) = sender.as_mut_player() {
|
if let Some(player) = sender.as_mut_player() {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
use pumpkin_core::text::TextComponent;
|
|
||||||
use pumpkin_core::GameMode;
|
use pumpkin_core::GameMode;
|
||||||
|
|
||||||
use crate::commands::arg_player::{consume_arg_player, parse_arg_player};
|
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| {
|
require(&|sender| sender.is_player()).execute(&|sender, _, args| {
|
||||||
let gamemode = parse_arg_gamemode(args)?;
|
let gamemode = parse_arg_gamemode(args)?;
|
||||||
|
|
||||||
return if let Player(target) = sender {
|
if let Player(target) = sender {
|
||||||
if target.gamemode.load() == gamemode {
|
if target.gamemode.load() == gamemode {
|
||||||
target.send_system_message(&TextComponent::text(&format!(
|
// target.send_system_message(&TextComponent::text(&format!(
|
||||||
"You already in {:?} gamemode",
|
// "You already in {:?} gamemode",
|
||||||
gamemode
|
// gamemode
|
||||||
)));
|
// )));
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
target.set_gamemode(gamemode);
|
// target.set_gamemode(gamemode);
|
||||||
target.send_system_message(&TextComponent::text(&format!(
|
// target.send_system_message(&TextComponent::text(&format!(
|
||||||
"Game mode was set to {:?}",
|
// "Game mode was set to {:?}",
|
||||||
gamemode
|
// gamemode
|
||||||
)));
|
// )));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(InvalidRequirementError)
|
Err(InvalidRequirementError)
|
||||||
};
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.with_child(argument(ARG_TARGET, consume_arg_player).execute(
|
.with_child(argument(ARG_TARGET, consume_arg_player).execute(
|
||||||
@ -104,7 +103,7 @@ pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
|||||||
// )));
|
// )));
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
target.set_gamemode(gamemode);
|
// target.set_gamemode(gamemode);
|
||||||
// sender.send_message(TextComponent::text(&format!(
|
// sender.send_message(TextComponent::text(&format!(
|
||||||
// "{}'s Game mode was set to {:?}",
|
// "{}'s Game mode was set to {:?}",
|
||||||
// target.gameprofile.name, gamemode
|
// target.gameprofile.name, gamemode
|
||||||
|
|||||||
@ -4,7 +4,6 @@ use crate::commands::tree::{Command, CommandTree, ConsumedArgs, RawArgs};
|
|||||||
use crate::commands::tree_builder::argument;
|
use crate::commands::tree_builder::argument;
|
||||||
use crate::commands::CommandSender;
|
use crate::commands::CommandSender;
|
||||||
use crate::server::Server;
|
use crate::server::Server;
|
||||||
use pumpkin_core::text::TextComponent;
|
|
||||||
|
|
||||||
const NAMES: [&str; 3] = ["help", "h", "?"];
|
const NAMES: [&str; 3] = ["help", "h", "?"];
|
||||||
|
|
||||||
@ -37,6 +36,8 @@ fn parse_arg_command<'a>(
|
|||||||
.map_err(|_| InvalidConsumptionError(Some(command_name.into())))
|
.map_err(|_| InvalidConsumptionError(Some(command_name.into())))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
|
||||||
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION)
|
CommandTree::new(NAMES, DESCRIPTION)
|
||||||
.with_child(
|
.with_child(
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
use crate::commands::arg_player::parse_arg_player;
|
use crate::commands::arg_player::parse_arg_player;
|
||||||
use crate::commands::tree::CommandTree;
|
use crate::commands::tree::CommandTree;
|
||||||
use crate::commands::tree_builder::argument;
|
use crate::commands::tree_builder::argument;
|
||||||
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
|
||||||
|
|
||||||
use super::arg_player::consume_arg_player;
|
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";
|
const ARG_TARGET: &str = "target";
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
|
|
||||||
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
||||||
argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| {
|
argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| {
|
||||||
dbg!("aa");
|
|
||||||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
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(
|
// sender.send_message(
|
||||||
TextComponent::text("Player has been kicked.").color_named(NamedColor::Blue),
|
// TextComponent::text("Player has been kicked.").color_named(NamedColor::Blue),
|
||||||
);
|
// );
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1,23 +1,24 @@
|
|||||||
use crate::commands::arg_player::{consume_arg_player, parse_arg_player};
|
use crate::commands::arg_player::{consume_arg_player, parse_arg_player};
|
||||||
use crate::commands::tree::CommandTree;
|
use crate::commands::tree::CommandTree;
|
||||||
use crate::commands::tree_builder::argument;
|
use crate::commands::tree_builder::argument;
|
||||||
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
|
||||||
|
|
||||||
const NAMES: [&str; 1] = ["kill"];
|
const NAMES: [&str; 1] = ["kill"];
|
||||||
const DESCRIPTION: &str = "Kills a target player.";
|
const DESCRIPTION: &str = "Kills a target player.";
|
||||||
|
|
||||||
const ARG_TARGET: &str = "target";
|
const ARG_TARGET: &str = "target";
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
|
|
||||||
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
||||||
argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| {
|
argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| {
|
||||||
// TODO parse entities not only players
|
// TODO parse entities not only players
|
||||||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
||||||
target.living_entity.kill();
|
// target.living_entity.kill();
|
||||||
|
|
||||||
sender.send_message(
|
// sender.send_message(
|
||||||
TextComponent::text("Player has been killed.").color_named(NamedColor::Blue),
|
// TextComponent::text("Player has been killed.").color_named(NamedColor::Blue),
|
||||||
);
|
// );
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
use crate::commands::tree::CommandTree;
|
||||||
use pumpkin_protocol::CURRENT_MC_PROTOCOL;
|
|
||||||
|
|
||||||
use crate::{commands::tree::CommandTree, server::CURRENT_MC_VERSION};
|
|
||||||
|
|
||||||
const NAMES: [&str; 1] = ["pumpkin"];
|
const NAMES: [&str; 1] = ["pumpkin"];
|
||||||
|
|
||||||
const DESCRIPTION: &str = "Display information about Pumpkin.";
|
const DESCRIPTION: &str = "Display information about Pumpkin.";
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
|
|
||||||
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, _, _| {
|
CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, _, _| {
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
use pumpkin_core::text::color::NamedColor;
|
|
||||||
use pumpkin_core::text::TextComponent;
|
|
||||||
|
|
||||||
use crate::commands::tree::CommandTree;
|
use crate::commands::tree::CommandTree;
|
||||||
use crate::commands::tree_builder::require;
|
use crate::commands::tree_builder::require;
|
||||||
|
|
||||||
@ -10,9 +7,9 @@ const DESCRIPTION: &str = "Stop the server.";
|
|||||||
|
|
||||||
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
pub fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
||||||
require(&|sender| sender.permission_lvl() >= 4).execute(&|sender, _, _args| {
|
require(&|sender| sender.permission_lvl() >= 4).execute(&|_sender, _, _args| {
|
||||||
sender
|
// sender
|
||||||
.send_message(TextComponent::text("Stopping Server").color_named(NamedColor::Red));
|
// .send_message(TextComponent::text("Stopping Server").color_named(NamedColor::Red));
|
||||||
std::process::exit(0)
|
std::process::exit(0)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -39,6 +39,7 @@ pub enum Command<'a> {
|
|||||||
Alias(&'a str),
|
Alias(&'a str),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
pub struct CommandTree<'a> {
|
pub struct CommandTree<'a> {
|
||||||
pub(crate) nodes: Vec<Node<'a>>,
|
pub(crate) nodes: Vec<Node<'a>>,
|
||||||
pub(crate) children: Vec<usize>,
|
pub(crate) children: Vec<usize>,
|
||||||
|
|||||||
@ -320,7 +320,8 @@ impl Player {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
SChatCommand::PACKET_ID => {
|
SChatCommand::PACKET_ID => {
|
||||||
self.handle_chat_command(server, SChatCommand::read(bytebuf)?);
|
self.handle_chat_command(server, SChatCommand::read(bytebuf)?)
|
||||||
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
SPlayerPosition::PACKET_ID => {
|
SPlayerPosition::PACKET_ID => {
|
||||||
|
|||||||
@ -88,10 +88,10 @@ async fn main() -> io::Result<()> {
|
|||||||
|
|
||||||
init_logger();
|
init_logger();
|
||||||
|
|
||||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
// let rt = tokio::runtime::Builder::new_multi_thread()
|
||||||
.enable_all()
|
// .enable_all()
|
||||||
.build()
|
// .build()
|
||||||
.unwrap();
|
// .unwrap();
|
||||||
|
|
||||||
ctrlc::set_handler(|| {
|
ctrlc::set_handler(|| {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
@ -141,7 +141,9 @@ async fn main() -> io::Result<()> {
|
|||||||
|
|
||||||
if !out.is_empty() {
|
if !out.is_empty() {
|
||||||
let dispatcher = server.command_dispatcher.clone();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -262,7 +262,7 @@ impl World {
|
|||||||
level.fetch_chunks(&chunks, sender, closed)
|
level.fetch_chunks(&chunks, sender, closed)
|
||||||
});
|
});
|
||||||
|
|
||||||
let client = client.clone();
|
let client = client;
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
while let Some(chunk_data) = chunk_receiver.recv().await {
|
while let Some(chunk_data) = chunk_receiver.recv().await {
|
||||||
// dbg!(chunk_pos);
|
// dbg!(chunk_pos);
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use pumpkin_core::math::{
|
|||||||
use pumpkin_protocol::client::play::CCenterChunk;
|
use pumpkin_protocol::client::play::CCenterChunk;
|
||||||
use pumpkin_world::cylindrical_chunk_iterator::Cylindrical;
|
use pumpkin_world::cylindrical_chunk_iterator::Cylindrical;
|
||||||
|
|
||||||
use crate::entity::{player::Player, Entity};
|
use crate::entity::player::Player;
|
||||||
|
|
||||||
use super::World;
|
use super::World;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ pub async fn player_join(world: &World, player: Arc<Player>) {
|
|||||||
|chunk_pos| {
|
|chunk_pos| {
|
||||||
loading_chunks.push(chunk_pos);
|
loading_chunks.push(chunk_pos);
|
||||||
},
|
},
|
||||||
|chunk_pos| {
|
|_| {
|
||||||
// player
|
// player
|
||||||
// .client
|
// .client
|
||||||
// .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z));
|
// .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z));
|
||||||
@ -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 current_watched = player.watched_section.load();
|
||||||
let new_watched = chunk_section_from_pos(&entity.block_pos.load());
|
let new_watched = chunk_section_from_pos(&entity.block_pos.load());
|
||||||
if current_watched != new_watched {
|
if current_watched != new_watched {
|
||||||
@ -89,7 +90,7 @@ pub async fn update_position(entity: &Entity, player: &Player) {
|
|||||||
|chunk_pos| {
|
|chunk_pos| {
|
||||||
loading_chunks.push(chunk_pos);
|
loading_chunks.push(chunk_pos);
|
||||||
},
|
},
|
||||||
|chunk_pos| {
|
|_| {
|
||||||
// player
|
// player
|
||||||
// .client
|
// .client
|
||||||
// .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z));
|
// .send_packet(&CUnloadChunk::new(chunk_pos.x, chunk_pos.z));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user