mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Migrate a bunch of PluginManager->callEvent() usages to Event->call
This has the triple bonus effect of a) making a lot of code easier to read, b) reducing Server::getInstance() usages, and c) removing a whole bunch of Server dependencies. The network and block namespaces are untouched by this commit due to potential for merge conflicts. These should be dealt with separately on master.
This commit is contained in:
@ -205,7 +205,8 @@ abstract class Living extends Entity implements Damageable{
|
||||
if(isset($this->effects[$effectId])){
|
||||
$effect = $this->effects[$effectId];
|
||||
$hasExpired = $effect->hasExpired();
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityEffectRemoveEvent($this, $effect));
|
||||
$ev = new EntityEffectRemoveEvent($this, $effect);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
if($hasExpired and !$ev->getEffect()->hasExpired()){ //altered duration of an expired effect to make it not get removed
|
||||
$this->sendEffectAdd($ev->getEffect(), true);
|
||||
@ -278,7 +279,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
$ev = new EntityEffectAddEvent($this, $effect, $oldEffect);
|
||||
$ev->setCancelled($cancelled);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -621,7 +622,8 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
protected function onDeath() : void{
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops()));
|
||||
$ev = new EntityDeathEvent($this, $this->getDrops());
|
||||
$ev->call();
|
||||
foreach($ev->getDrops() as $item){
|
||||
$this->getLevel()->dropItem($this, $item);
|
||||
}
|
||||
|
Reference in New Issue
Block a user