示例#1
0
 /**
  * Calls an event
  *
  * @param Event $event
  */
 public function callEvent(Event $event)
 {
     foreach ($event->getHandlers()->getRegisteredListeners() as $registration) {
         if (!$registration->getPlugin()->isEnabled()) {
             continue;
         }
         try {
             $registration->callEvent($event);
         } catch (\Exception $e) {
             $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.eventError", [$event->getEventName(), $registration->getPlugin()->getDescription()->getFullName(), $e->getMessage(), get_class($registration->getListener())]));
             $logger = $this->server->getLogger();
             if ($logger instanceof MainLogger) {
                 $logger->logException($e);
             }
         }
     }
     if ($this->server->getAIHolder() != null) {
         if ($event instanceof EntityDeathEvent) {
             $this->server->getAIHolder()->MobDeath($event);
         }
         if ($event instanceof EntityDamageByEntityEvent) {
             $this->server->getAIHolder()->EntityDamage($event);
         }
     }
 }