Remove GarbageServerboundPacket

it's not the protocol implementation's job to decide what's garbage. It should only indicate that a packet MAY be sent by the client. It should then be up to the handler to decide what to do with it.
This commit is contained in:
Dylan K. Taylor 2021-04-19 01:07:21 +01:00
parent 6845cbb2b3
commit 66fdf526d4
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 6 additions and 41 deletions

View File

@ -59,7 +59,6 @@ use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
use pocketmine\network\mcpe\protocol\ClientboundPacket;
use pocketmine\network\mcpe\protocol\DisconnectPacket;
use pocketmine\network\mcpe\protocol\GarbageServerboundPacket;
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
use pocketmine\network\mcpe\protocol\MobEffectPacket;
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
@ -376,10 +375,6 @@ class NetworkSession{
*/
public function handleDataPacket(Packet $packet, string $buffer) : void{
if(!($packet instanceof ServerboundPacket)){
if($packet instanceof GarbageServerboundPacket){
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($buffer));
return;
}
throw new PacketHandlingException("Unexpected non-serverbound packet");
}

View File

@ -76,6 +76,7 @@ use pocketmine\network\mcpe\protocol\PlayerInputPacket;
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
use pocketmine\network\mcpe\protocol\SetActorMotionPacket;
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
@ -581,6 +582,10 @@ class InGamePacketHandler extends PacketHandler{
return true;
}
public function handleSetActorMotion(SetActorMotionPacket $packet) : bool{
return true; //Not used: This packet is (erroneously) sent to the server when the client is riding a vehicle.
}
public function handleAnimate(AnimatePacket $packet) : bool{
return true; //Not used
}

View File

@ -1,32 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
/**
* This interface can be implemented by packets which are erroneously sent to the server by a buggy client to filter
* them out.
*/
interface GarbageServerboundPacket extends Packet{
}

View File

@ -28,10 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
/**
* TODO: This packet is (erroneously) sent to the server when the client is riding a vehicle.
*/
class SetActorMotionPacket extends DataPacket implements ClientboundPacket, GarbageServerboundPacket{
class SetActorMotionPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::SET_ACTOR_MOTION_PACKET;
/** @var int */