Handle invalid player commands
This commit is contained in:
parent
eeefd1d51a
commit
740a98a068
@ -7,7 +7,7 @@ use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
|
||||
#[packet(0x25)]
|
||||
pub struct SPlayerCommand {
|
||||
pub entitiy_id: VarInt,
|
||||
pub action: Action,
|
||||
pub action: VarInt,
|
||||
pub jump_boost: VarInt,
|
||||
}
|
||||
#[derive(FromPrimitive)]
|
||||
@ -27,7 +27,7 @@ impl ServerPacket for SPlayerCommand {
|
||||
fn read(bytebuf: &mut crate::bytebuf::ByteBuffer) -> Result<Self, DeserializerError> {
|
||||
Ok(Self {
|
||||
entitiy_id: bytebuf.get_var_int(),
|
||||
action: Action::from_i32(bytebuf.get_var_int().into()).unwrap(),
|
||||
action: bytebuf.get_var_int(),
|
||||
jump_boost: bytebuf.get_var_int(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -4,10 +4,10 @@ use pumpkin_inventory::WindowType;
|
||||
use pumpkin_protocol::{
|
||||
client::play::{
|
||||
Animation, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation, COpenScreen,
|
||||
CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
||||
CSetEntityMetadata, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot, Metadata,
|
||||
},
|
||||
server::play::{
|
||||
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
||||
SSwingArm,
|
||||
},
|
||||
@ -17,7 +17,7 @@ use pumpkin_text::TextComponent;
|
||||
|
||||
use crate::{
|
||||
commands::{handle_command, CommandSender},
|
||||
entity::player::{ChatMode, GameMode, Hand},
|
||||
entity::player::{ChatMode, GameMode, Hand, Player},
|
||||
server::Server,
|
||||
util::math::wrap_degrees,
|
||||
};
|
||||
@ -176,7 +176,8 @@ impl Client {
|
||||
return;
|
||||
}
|
||||
|
||||
match command.action {
|
||||
if let Some(action) = Action::from_i32(command.action.0 as i32) {
|
||||
match action {
|
||||
pumpkin_protocol::server::play::Action::StartSneaking => player.sneaking = true,
|
||||
pumpkin_protocol::server::play::Action::StopSneaking => player.sneaking = false,
|
||||
pumpkin_protocol::server::play::Action::LeaveBed => todo!(),
|
||||
@ -185,7 +186,10 @@ impl Client {
|
||||
pumpkin_protocol::server::play::Action::StartHourseJump => todo!(),
|
||||
pumpkin_protocol::server::play::Action::StopHourseJump => todo!(),
|
||||
pumpkin_protocol::server::play::Action::OpenVehicleInventory => todo!(),
|
||||
pumpkin_protocol::server::play::Action::StartFlyingElytra => {}, // TODO
|
||||
pumpkin_protocol::server::play::Action::StartFlyingElytra => {} // TODO
|
||||
}
|
||||
} else {
|
||||
self.kick("Invalid player command")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user