mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
NetworkBinaryStream: swap BadPacketException for PacketDecodeException
This commit is contained in:
parent
098a5518a6
commit
09e994a026
@ -30,7 +30,7 @@ use pocketmine\math\Vector3;
|
|||||||
use pocketmine\nbt\NbtDataException;
|
use pocketmine\nbt\NbtDataException;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\TreeRoot;
|
use pocketmine\nbt\TreeRoot;
|
||||||
use pocketmine\network\BadPacketException;
|
use pocketmine\network\mcpe\protocol\PacketDecodeException;
|
||||||
use pocketmine\network\mcpe\protocol\types\command\CommandOriginData;
|
use pocketmine\network\mcpe\protocol\types\command\CommandOriginData;
|
||||||
use pocketmine\network\mcpe\protocol\types\entity\Attribute;
|
use pocketmine\network\mcpe\protocol\types\entity\Attribute;
|
||||||
use pocketmine\network\mcpe\protocol\types\entity\BlockPosMetadataProperty;
|
use pocketmine\network\mcpe\protocol\types\entity\BlockPosMetadataProperty;
|
||||||
@ -190,7 +190,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
try{
|
try{
|
||||||
return new SkinImage($height, $width, $data);
|
return new SkinImage($height, $width, $data);
|
||||||
}catch(\InvalidArgumentException $e){
|
}catch(\InvalidArgumentException $e){
|
||||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
throw new PacketDecodeException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BadPacketException
|
* @throws PacketDecodeException
|
||||||
* @throws BinaryDataException
|
* @throws BinaryDataException
|
||||||
*/
|
*/
|
||||||
public function getSlot() : ItemStack{
|
public function getSlot() : ItemStack{
|
||||||
@ -221,15 +221,15 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
if($nbtLen === 0xffff){
|
if($nbtLen === 0xffff){
|
||||||
$c = $this->getByte();
|
$c = $this->getByte();
|
||||||
if($c !== 1){
|
if($c !== 1){
|
||||||
throw new BadPacketException("Unexpected NBT count $c");
|
throw new PacketDecodeException("Unexpected NBT count $c");
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
$compound = (new NetworkNbtSerializer())->read($this->buffer, $this->offset, 512)->mustGetCompoundTag();
|
$compound = (new NetworkNbtSerializer())->read($this->buffer, $this->offset, 512)->mustGetCompoundTag();
|
||||||
}catch(NbtDataException $e){
|
}catch(NbtDataException $e){
|
||||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
throw new PacketDecodeException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
}elseif($nbtLen !== 0){
|
}elseif($nbtLen !== 0){
|
||||||
throw new BadPacketException("Unexpected fake NBT length $nbtLen");
|
throw new PacketDecodeException("Unexpected fake NBT length $nbtLen");
|
||||||
}
|
}
|
||||||
|
|
||||||
$canPlaceOn = [];
|
$canPlaceOn = [];
|
||||||
@ -312,7 +312,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
* @return MetadataProperty[]
|
* @return MetadataProperty[]
|
||||||
* @phpstan-return array<int, MetadataProperty>
|
* @phpstan-return array<int, MetadataProperty>
|
||||||
*
|
*
|
||||||
* @throws BadPacketException
|
* @throws PacketDecodeException
|
||||||
* @throws BinaryDataException
|
* @throws BinaryDataException
|
||||||
*/
|
*/
|
||||||
public function getEntityMetadata() : array{
|
public function getEntityMetadata() : array{
|
||||||
@ -340,7 +340,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
case LongMetadataProperty::id(): return LongMetadataProperty::read($this);
|
case LongMetadataProperty::id(): return LongMetadataProperty::read($this);
|
||||||
case Vec3MetadataProperty::id(): return Vec3MetadataProperty::read($this);
|
case Vec3MetadataProperty::id(): return Vec3MetadataProperty::read($this);
|
||||||
default:
|
default:
|
||||||
throw new BadPacketException("Unknown entity metadata type " . $type);
|
throw new PacketDecodeException("Unknown entity metadata type " . $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
* Reads a list of Attributes from the stream.
|
* Reads a list of Attributes from the stream.
|
||||||
* @return Attribute[]
|
* @return Attribute[]
|
||||||
*
|
*
|
||||||
* @throws BadPacketException if reading an attribute with an unrecognized name
|
* @throws PacketDecodeException if reading an attribute with an unrecognized name
|
||||||
* @throws BinaryDataException
|
* @throws BinaryDataException
|
||||||
*/
|
*/
|
||||||
public function getAttributeList() : array{
|
public function getAttributeList() : array{
|
||||||
@ -537,7 +537,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
* @return mixed[][], members are in the structure [name => [type, value]]
|
* @return mixed[][], members are in the structure [name => [type, value]]
|
||||||
* @phpstan-return array<string, array{0: int, 1: bool|int|float}>
|
* @phpstan-return array<string, array{0: int, 1: bool|int|float}>
|
||||||
*
|
*
|
||||||
* @throws BadPacketException
|
* @throws PacketDecodeException
|
||||||
* @throws BinaryDataException
|
* @throws BinaryDataException
|
||||||
*/
|
*/
|
||||||
public function getGameRules() : array{
|
public function getGameRules() : array{
|
||||||
@ -558,7 +558,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
$value = $this->getLFloat();
|
$value = $this->getLFloat();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new BadPacketException("Unknown gamerule type $type");
|
throw new PacketDecodeException("Unknown gamerule type $type");
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules[$name] = [$type, $value];
|
$rules[$name] = [$type, $value];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user