Merge branch 'release/3.3'

This commit is contained in:
Dylan K. Taylor
2018-10-05 18:11:33 +01:00
28 changed files with 182 additions and 139 deletions

View File

@ -542,7 +542,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->level->addEntity($this);
$this->lastUpdate = $this->server->getTick();
$this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
(new EntitySpawnEvent($this))->call();
$this->scheduleUpdate();
@ -882,7 +882,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
* @param EntityDamageEvent $source
*/
public function attack(EntityDamageEvent $source) : void{
$this->server->getPluginManager()->callEvent($source);
$source->call();
if($source->isCancelled()){
return;
}
@ -896,7 +896,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
* @param EntityRegainHealthEvent $source
*/
public function heal(EntityRegainHealthEvent $source) : void{
$this->server->getPluginManager()->callEvent($source);
$source->call();
if($source->isCancelled()){
return;
}
@ -1795,7 +1795,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public function setMotion(Vector3 $motion) : bool{
if(!$this->justCreated){
$this->server->getPluginManager()->callEvent($ev = new EntityMotionEvent($this, $motion));
$ev = new EntityMotionEvent($this, $motion);
$ev->call();
if($ev->isCancelled()){
return false;
}
@ -1828,7 +1829,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
$from = Position::fromObject($this, $this->level);
$to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->level);
$this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
$ev = new EntityTeleportEvent($this, $from, $to);
$ev->call();
if($ev->isCancelled()){
return false;
}
@ -1854,7 +1856,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
if($this->isValid()){
$this->server->getPluginManager()->callEvent($ev = new EntityLevelChangeEvent($this, $this->level, $targetLevel));
$ev = new EntityLevelChangeEvent($this, $this->level, $targetLevel);
$ev->call();
if($ev->isCancelled()){
return false;
}
@ -1980,7 +1983,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
*/
public function close() : void{
if(!$this->closed){
$this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));
(new EntityDespawnEvent($this))->call();
$this->closed = true;
$this->despawnFromAll();