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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@ -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(())
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<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 /{}",
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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(())
|
||||
}),
|
||||
|
||||
@ -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(())
|
||||
}),
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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)
|
||||
}),
|
||||
)
|
||||
|
||||
@ -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>,
|
||||
|
||||
@ -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 => {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<Player>) {
|
||||
|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<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 {
|
||||
@ -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));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user