Use more appropriate exceptions in the protocol layer

This commit is contained in:
Dylan K. Taylor
2019-01-03 17:57:06 +00:00
parent 504cc3bf8b
commit 0f941410f6
7 changed files with 21 additions and 8 deletions

View File

@ -68,12 +68,20 @@ abstract class DataPacket extends NetworkBinaryStream{
return false;
}
/**
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
public function decode(){
$this->offset = 0;
$this->decodeHeader();
$this->decodePayload();
}
/**
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
protected function decodeHeader(){
$pid = $this->getUnsignedVarInt();
if($pid !== static::NETWORK_ID){
@ -83,6 +91,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(){