Remove unnecessary trait

This commit is contained in:
lukas0008 2024-08-05 15:23:04 +02:00
parent 3378b76b36
commit e079b23bd9
2 changed files with 6 additions and 22 deletions

View File

@ -12,7 +12,6 @@ use crate::{
use authentication::GameProfile; use authentication::GameProfile;
use mio::{event::Event, net::TcpStream, Token}; use mio::{event::Event, net::TcpStream, Token};
use player_packet::PlayerPacketProcessor;
use pumpkin_protocol::{ use pumpkin_protocol::{
client::{ client::{
config::CConfigDisconnect, config::CConfigDisconnect,

View File

@ -9,24 +9,9 @@ use crate::{
use super::Client; use super::Client;
// implement player packets
pub trait PlayerPacketProcessor {
fn handle_confirm_teleport(&mut self, server: &mut Server, confirm_teleport: SConfirmTeleport);
fn handle_chat_command(&mut self, server: &mut Server, command: SChatCommand); impl Client {
pub fn handle_confirm_teleport(
fn handle_position(&mut self, server: &mut Server, position: SPlayerPosition);
fn handle_position_rotation(
&mut self,
server: &mut Server,
position_rotation: SPlayerPositionRotation,
);
fn handle_rotation(&mut self, server: &mut Server, rotation: SPlayerRotation);
}
impl PlayerPacketProcessor for Client {
fn handle_confirm_teleport(
&mut self, &mut self,
_server: &mut Server, _server: &mut Server,
confirm_teleport: SConfirmTeleport, confirm_teleport: SConfirmTeleport,
@ -43,7 +28,7 @@ impl PlayerPacketProcessor for Client {
} }
} }
fn handle_position(&mut self, _server: &mut Server, position: SPlayerPosition) { pub fn handle_position(&mut self, _server: &mut Server, position: SPlayerPosition) {
if position.x.is_nan() || position.feet_y.is_nan() || position.z.is_nan() { if position.x.is_nan() || position.feet_y.is_nan() || position.z.is_nan() {
self.kick("Invalid movement"); self.kick("Invalid movement");
} }
@ -53,7 +38,7 @@ impl PlayerPacketProcessor for Client {
player.z = position.z; player.z = position.z;
} }
fn handle_position_rotation( pub fn handle_position_rotation(
&mut self, &mut self,
_server: &mut Server, _server: &mut Server,
position_rotation: SPlayerPositionRotation, position_rotation: SPlayerPositionRotation,
@ -75,7 +60,7 @@ impl PlayerPacketProcessor for Client {
player.pitch = position_rotation.pitch; player.pitch = position_rotation.pitch;
} }
fn handle_rotation(&mut self, _server: &mut Server, rotation: SPlayerRotation) { pub fn handle_rotation(&mut self, _server: &mut Server, rotation: SPlayerRotation) {
if !rotation.yaw.is_finite() || !rotation.pitch.is_finite() { if !rotation.yaw.is_finite() || !rotation.pitch.is_finite() {
self.kick("Invalid rotation"); self.kick("Invalid rotation");
} }
@ -84,7 +69,7 @@ impl PlayerPacketProcessor for Client {
player.pitch = rotation.pitch; player.pitch = rotation.pitch;
} }
fn handle_chat_command(&mut self, server: &mut Server, command: SChatCommand) { pub fn handle_chat_command(&mut self, server: &mut Server, command: SChatCommand) {
handle_command(&mut CommandSender::Player(self), command.command, server); handle_command(&mut CommandSender::Player(self), command.command, server);
} }
} }