mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 12:55:21 +00:00
Make use of BadPacketException::wrap()
This commit is contained in:
parent
2d46ae4476
commit
3e5d3a646b
@ -271,7 +271,7 @@ class NetworkSession{
|
|||||||
$payload = $this->cipher->decrypt($payload);
|
$payload = $this->cipher->decrypt($payload);
|
||||||
}catch(\UnexpectedValueException $e){
|
}catch(\UnexpectedValueException $e){
|
||||||
$this->logger->debug("Encrypted packet: " . base64_encode($payload));
|
$this->logger->debug("Encrypted packet: " . base64_encode($payload));
|
||||||
throw new BadPacketException("Packet decryption error: " . $e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e, "Packet decryption error");
|
||||||
}finally{
|
}finally{
|
||||||
Timings::$playerNetworkReceiveDecryptTimer->stopTiming();
|
Timings::$playerNetworkReceiveDecryptTimer->stopTiming();
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ class NetworkSession{
|
|||||||
}catch(\ErrorException $e){
|
}catch(\ErrorException $e){
|
||||||
$this->logger->debug("Failed to decompress packet: " . base64_encode($payload));
|
$this->logger->debug("Failed to decompress packet: " . base64_encode($payload));
|
||||||
//TODO: this isn't incompatible game version if we already established protocol version
|
//TODO: this isn't incompatible game version if we already established protocol version
|
||||||
throw new BadPacketException("Compressed packet batch decode error: " . $e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e, "Compressed packet batch decode error");
|
||||||
}finally{
|
}finally{
|
||||||
Timings::$playerNetworkReceiveDecompressTimer->stopTiming();
|
Timings::$playerNetworkReceiveDecompressTimer->stopTiming();
|
||||||
}
|
}
|
||||||
@ -297,14 +297,14 @@ class NetworkSession{
|
|||||||
$pk = $stream->getPacket();
|
$pk = $stream->getPacket();
|
||||||
}catch(BinaryDataException $e){
|
}catch(BinaryDataException $e){
|
||||||
$this->logger->debug("Packet batch: " . base64_encode($stream->getBuffer()));
|
$this->logger->debug("Packet batch: " . base64_encode($stream->getBuffer()));
|
||||||
throw new BadPacketException("Packet batch decode error: " . $e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e, "Packet batch decode error");
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$this->handleDataPacket($pk);
|
$this->handleDataPacket($pk);
|
||||||
}catch(BadPacketException $e){
|
}catch(BadPacketException $e){
|
||||||
$this->logger->debug($pk->getName() . ": " . base64_encode($pk->getBinaryStream()->getBuffer()));
|
$this->logger->debug($pk->getName() . ": " . base64_encode($pk->getBinaryStream()->getBuffer()));
|
||||||
throw new BadPacketException("Error processing " . $pk->getName() . ": " . $e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e, "Error processing " . $pk->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
$offset = 0;
|
$offset = 0;
|
||||||
$nbt = (new NetworkNbtSerializer())->read($packet->namedtag, $offset, 512)->mustGetCompoundTag();
|
$nbt = (new NetworkNbtSerializer())->read($packet->namedtag, $offset, 512)->mustGetCompoundTag();
|
||||||
}catch(NbtDataException $e){
|
}catch(NbtDataException $e){
|
||||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($block instanceof Sign){
|
if($block instanceof Sign){
|
||||||
@ -552,7 +552,7 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
try{
|
try{
|
||||||
$text = SignText::fromBlob($nbt->getString("Text"));
|
$text = SignText::fromBlob($nbt->getString("Text"));
|
||||||
}catch(\InvalidArgumentException $e){
|
}catch(\InvalidArgumentException $e){
|
||||||
throw new BadPacketException("Invalid sign text update: " . $e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e, "Invalid sign text update");
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@ -560,7 +560,7 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
$this->player->getWorld()->sendBlocks([$this->player], [$pos]);
|
$this->player->getWorld()->sendBlocks([$this->player], [$pos]);
|
||||||
}
|
}
|
||||||
}catch(\UnexpectedValueException $e){
|
}catch(\UnexpectedValueException $e){
|
||||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -198,7 +198,7 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
|
|||||||
$attr->setMaxValue($max);
|
$attr->setMaxValue($max);
|
||||||
$attr->setValue($current);
|
$attr->setValue($current);
|
||||||
}catch(\InvalidArgumentException $e){
|
}catch(\InvalidArgumentException $e){
|
||||||
throw new BadPacketException($e->getMessage(), 0, $e); //TODO: address this properly
|
throw BadPacketException::wrap($e); //TODO: address this properly
|
||||||
}
|
}
|
||||||
$this->attributes[] = $attr;
|
$this->attributes[] = $attr;
|
||||||
}else{
|
}else{
|
||||||
|
@ -128,7 +128,7 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
|||||||
try{
|
try{
|
||||||
$entry["input"] = ItemFactory::get($inputId, $inputData);
|
$entry["input"] = ItemFactory::get($inputId, $inputData);
|
||||||
}catch(\InvalidArgumentException $e){
|
}catch(\InvalidArgumentException $e){
|
||||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e);
|
||||||
}
|
}
|
||||||
$entry["output"] = $out = $in->getSlot();
|
$entry["output"] = $out = $in->getSlot();
|
||||||
if($out->getMeta() === 0x7fff){
|
if($out->getMeta() === 0x7fff){
|
||||||
|
@ -82,7 +82,7 @@ abstract class DataPacket implements Packet{
|
|||||||
$this->decodeHeader($this->buf);
|
$this->decodeHeader($this->buf);
|
||||||
$this->decodePayload($this->buf);
|
$this->decodePayload($this->buf);
|
||||||
}catch(BinaryDataException | BadPacketException $e){
|
}catch(BinaryDataException | BadPacketException $e){
|
||||||
throw new BadPacketException($this->getName() . ": " . $e->getMessage(), 0, $e);
|
throw BadPacketException::wrap($e, $this->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user