mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Explosion: add exception throws for bad arguments
This commit is contained in:
parent
69b3bb183d
commit
f2f8c235e7
@ -71,11 +71,18 @@ class Explosion{
|
||||
* @param Entity|Block $what
|
||||
*/
|
||||
public function __construct(Position $center, float $size, $what = null){
|
||||
$this->level = $center->getLevel();
|
||||
$this->source = $center;
|
||||
$this->size = max($size, 0);
|
||||
$this->what = $what;
|
||||
$this->level = $center->getLevel();
|
||||
if($this->level === null){
|
||||
throw new \InvalidArgumentException("Position does not have a valid level");
|
||||
}
|
||||
|
||||
if($size <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $size");
|
||||
}
|
||||
$this->size = $size;
|
||||
|
||||
$this->what = $what;
|
||||
$this->subChunkHandler = new SubChunkIteratorManager($this->level, false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user