Replaced Position->getLevel() null checks with isValid()

This commit is contained in:
Dylan K. Taylor
2018-03-20 11:10:36 +00:00
parent 73e09392b6
commit 1648fff916
7 changed files with 22 additions and 23 deletions

View File

@ -71,11 +71,11 @@ class Explosion{
* @param Entity|Block $what
*/
public function __construct(Position $center, float $size, $what = null){
$this->source = $center;
$this->level = $center->getLevel();
if($this->level === null){
if(!$center->isValid()){
throw new \InvalidArgumentException("Position does not have a valid level");
}
$this->source = $center;
$this->level = $center->getLevel();
if($size <= 0){
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $size");