Added API method Entity->isClosed() and made Entity->closed protected

This commit is contained in:
Dylan K. Taylor
2017-08-16 19:30:23 +01:00
parent 20aa519f3a
commit eebc52e00b
7 changed files with 21 additions and 8 deletions

View File

@ -352,7 +352,7 @@ abstract class Entity extends Location implements Metadatable{
protected $server;
/** @var bool */
public $closed = false;
protected $closed = false;
/** @var TimingsHandler */
protected $timings;
@ -1826,6 +1826,19 @@ abstract class Entity extends Location implements Metadatable{
}
}
/**
* Returns whether the entity has been "closed".
* @return bool
*/
public function isClosed() : bool{
return $this->closed;
}
/**
* Closes the entity and frees attached references.
*
* WARNING: Entities are unusable after this has been executed!
*/
public function close(){
if(!$this->closed){
$this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));