mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 13:14:54 +00:00
Throw exceptions when trying to add closed entities or tiles to levels
This commit is contained in:
parent
30211bee82
commit
7b04049bb7
@ -2479,9 +2479,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @throws LevelException
|
* @throws LevelException
|
||||||
*/
|
*/
|
||||||
public function addEntity(Entity $entity){
|
public function addEntity(Entity $entity){
|
||||||
|
if($entity->isClosed()){
|
||||||
|
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to Level");
|
||||||
|
}
|
||||||
if($entity->getLevel() !== $this){
|
if($entity->getLevel() !== $this){
|
||||||
throw new LevelException("Invalid Entity level");
|
throw new LevelException("Invalid Entity level");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($entity instanceof Player){
|
if($entity instanceof Player){
|
||||||
$this->players[$entity->getId()] = $entity;
|
$this->players[$entity->getId()] = $entity;
|
||||||
}
|
}
|
||||||
@ -2494,6 +2498,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @throws LevelException
|
* @throws LevelException
|
||||||
*/
|
*/
|
||||||
public function addTile(Tile $tile){
|
public function addTile(Tile $tile){
|
||||||
|
if($tile->isClosed()){
|
||||||
|
throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to Level");
|
||||||
|
}
|
||||||
if($tile->getLevel() !== $this){
|
if($tile->getLevel() !== $this){
|
||||||
throw new LevelException("Invalid Tile level");
|
throw new LevelException("Invalid Tile level");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user