Merge branch '3.5'

This commit is contained in:
Dylan K. Taylor 2019-01-03 18:02:33 +00:00
commit 60687d8d6c
5 changed files with 16 additions and 4 deletions

View File

@ -109,7 +109,7 @@ class BookEditPacket extends DataPacket{
$this->putString($this->xuid); $this->putString($this->xuid);
break; break;
default: default:
throw new \UnexpectedValueException("Unknown book edit type $this->type!"); throw new \InvalidArgumentException("Unknown book edit type $this->type!");
} }
} }

View File

@ -91,7 +91,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){ }elseif($object->type === MapTrackedObject::TYPE_ENTITY){
$object->entityUniqueId = $this->getEntityUniqueId(); $object->entityUniqueId = $this->getEntityUniqueId();
}else{ }else{
throw new \UnexpectedValueException("Unknown map object type"); throw new \UnexpectedValueException("Unknown map object type $object->type");
} }
$this->trackedEntities[] = $object; $this->trackedEntities[] = $object;
} }
@ -163,7 +163,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){ }elseif($object->type === MapTrackedObject::TYPE_ENTITY){
$this->putEntityUniqueId($object->entityUniqueId); $this->putEntityUniqueId($object->entityUniqueId);
}else{ }else{
throw new \UnexpectedValueException("Unknown map object type"); throw new \InvalidArgumentException("Unknown map object type $object->type");
} }
} }

View File

@ -61,12 +61,20 @@ abstract class DataPacket extends NetworkBinaryStream{
return false; return false;
} }
/**
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
public function decode() : void{ public function decode() : void{
$this->rewind(); $this->rewind();
$this->decodeHeader(); $this->decodeHeader();
$this->decodePayload(); $this->decodePayload();
} }
/**
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
protected function decodeHeader() : void{ protected function decodeHeader() : void{
$pid = $this->getUnsignedVarInt(); $pid = $this->getUnsignedVarInt();
if($pid !== static::NETWORK_ID){ if($pid !== static::NETWORK_ID){
@ -76,6 +84,9 @@ abstract class DataPacket extends NetworkBinaryStream{
/** /**
* Note for plugin developers: If you're adding your own packets, you should perform decoding in here. * Note for plugin developers: If you're adding your own packets, you should perform decoding in here.
*
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/ */
protected function decodePayload() : void{ protected function decodePayload() : void{

View File

@ -81,7 +81,7 @@ class SetScorePacket extends DataPacket{
$this->putString($entry->customName); $this->putString($entry->customName);
break; break;
default: default:
throw new \UnexpectedValueException("Unknown entry type $entry->type"); throw new \InvalidArgumentException("Unknown entry type $entry->type");
} }
} }
} }

View File

@ -159,6 +159,7 @@ class NetworkInventoryAction{
* @param Player $player * @param Player $player
* *
* @return InventoryAction|null * @return InventoryAction|null
*
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
*/ */
public function createInventoryAction(Player $player) : ?InventoryAction{ public function createInventoryAction(Player $player) : ?InventoryAction{