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);
break;
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){
$object->entityUniqueId = $this->getEntityUniqueId();
}else{
throw new \UnexpectedValueException("Unknown map object type");
throw new \UnexpectedValueException("Unknown map object type $object->type");
}
$this->trackedEntities[] = $object;
}
@ -163,7 +163,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
$this->putEntityUniqueId($object->entityUniqueId);
}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;
}
/**
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
public function decode() : void{
$this->rewind();
$this->decodeHeader();
$this->decodePayload();
}
/**
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
protected function decodeHeader() : void{
$pid = $this->getUnsignedVarInt();
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.
*
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
protected function decodePayload() : void{

View File

@ -81,7 +81,7 @@ class SetScorePacket extends DataPacket{
$this->putString($entry->customName);
break;
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
*
* @return InventoryAction|null
*
* @throws \UnexpectedValueException
*/
public function createInventoryAction(Player $player) : ?InventoryAction{