当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityDamageEvent::getDamager方法代码示例

本文整理汇总了PHP中pocketmine\event\entity\EntityDamageEvent::getDamager方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityDamageEvent::getDamager方法的具体用法?PHP EntityDamageEvent::getDamager怎么用?PHP EntityDamageEvent::getDamager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\entity\EntityDamageEvent的用法示例。


在下文中一共展示了EntityDamageEvent::getDamager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onDamage

 /**
  * @param EntityDamageEvent $event
  * @priority HIGH
  * @ignoreCancelled true
  */
 public function onDamage(EntityDamageEvent $event)
 {
     $damaged = $event->getEntity();
     if ($damaged instanceof Player) {
         $area = $this->main->getDatabase()->searchAreaByPosition($damaged);
         if ($area instanceof Area) {
             $cause = $event->getCause();
             if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED, false, false)) {
                 $event->setCancelled();
             } elseif ($cause === EntityDamageEvent::CAUSE_BLOCK_EXPLOSION) {
                 if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_EXPLOSION, false)) {
                     $event->setCancelled();
                 }
             } elseif ($cause === EntityDamageEvent::CAUSE_VOID) {
                 if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_VOID, false)) {
                     $event->setCancelled();
                 }
             } elseif ($cause === EntityDamageEvent::CAUSE_SUFFOCATION) {
                 if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_SUFFOCATE, false)) {
                     $event->setCancelled();
                 }
             } elseif ($cause === EntityDamageEvent::CAUSE_DROWNING) {
                 if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_DROWN, false)) {
                     $event->setCancelled();
                 }
             } elseif ($cause === EntityDamageEvent::CAUSE_FALL) {
                 if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_FALL, false)) {
                     $event->setCancelled();
                 }
             } elseif ($cause === EntityDamageEvent::CAUSE_FIRE or $cause === EntityDamageEvent::CAUSE_FIRE_TICK or $cause === EntityDamageEvent::CAUSE_LAVA) {
                 if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_FIRE, false)) {
                     $event->setCancelled();
                 }
             } elseif ($event instanceof EntityDamageByEntityEvent) {
                 $damager = $event->getDamager();
                 if ($damager instanceof Player) {
                     if ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_PLAYER, false)) {
                         $event->setCancelled();
                     }
                 } elseif ($this->areaHasFlag($damaged, Area::FLAG_DAMAGED_BY_ENTITY, false)) {
                     $event->setCancelled();
                 }
             }
         }
     }
     if (!$event->setCancelled() and $event instanceof EntityDamageByEntityEvent) {
         $damager = $event->getDamager();
         if ($damager instanceof Player) {
             if ($damaged instanceof Player) {
                 if (!$this->areaHasFlag($damager, Area::FLAG_DAMAGE_PLAYER, true)) {
                     $event->setCancelled();
                 }
             } elseif (!$this->areaHasFlag($damager, Area::FLAG_DAMAGE_MOB, true)) {
                 $event->setCancelled();
             }
         }
     }
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:63,代码来源:EventListener.php

示例2: onDeath

 public function onDeath(EntityDamageEvent $event)
 {
     $damage = $event->getDamage();
     $health = $event->getDamager()->getHealth();
     if ($health <= $damage) {
         $player = $event->getDamager();
         $money = $this->getConfig()->get("money");
         $player->sendMessage("You've Earned 8 Coins");
         $this->addMoney($player->getName(), $money);
     }
 }
开发者ID:RedEnder,项目名称:KillMoney,代码行数:11,代码来源:Main.php

示例3: onAttack

 public function onAttack(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent or $event instanceof EntityDamageByChildEntityEvent) {
         if ($event->getDamager() instanceof Player and $event->getEntity() instanceof Player) {
             $this->attackQueue[$event->getEntity()->getName()] = $event->getDamager()->getName();
         }
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:8,代码来源:PVPMoney.php

示例4: onHit

 public function onHit(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByChildEntityEvent) {
         $target = $event->getEntity();
         $player = $event->getDamager();
         $event->getDamager()->sendTip("§aYou hit§c " . $target->getName());
         $player->getLevel()->addSound(new AnvilFallSound($player), [$player]);
     }
 }
开发者ID:CaptainKenji17,项目名称:ArrowHit,代码行数:9,代码来源:Main.php

示例5: EntityDamageEvent

 /**
  * @param EnityDamageEvent $event
  *
  * @priority LOW
  * @ignoreCancelled true
  */
 public function EntityDamageEvent(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         if ($event->getDamager() instanceof Player) {
             foreach (array($event->getDamager(), $event->getEntity()) as $players) {
                 $this->setTime($players);
             }
         }
     }
 }
开发者ID:kdani1,项目名称:CombatLogger,代码行数:16,代码来源:Main.php

示例6: onAttack

 public function onAttack(EntityDamageEvent $event)
 {
     if (!$event instanceof EntityDamageByEntityEvent) {
         return;
     }
     if ($event->getEntity() instanceof Player and $event->getDamager() instanceof Player) {
         if ($event->getEntity()->distance($event->getDamager()) > 7) {
             $event->setCancelled();
         }
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:11,代码来源:placebo.php

示例7: onEntityDamage

 public function onEntityDamage(EntityDamageEvent $event)
 {
     if (!$event->isCancelled() && $event instanceof EntityDamageByEntityEvent) {
         $e = $event->getEntity();
         $arrow = $event->getDamager();
         $damage = round($event->getDamage() / 2);
         if ($arrow instanceof AbilityArrow) {
             $shoter = $arrow->shootingEntity;
             if ($shoter instanceof Player) {
                 if ($arrow instanceof FireArrow) {
                     $e->setOnFire(rand(3, 10));
                 } elseif ($arrow instanceof TeleportArrow) {
                     $shoter->teleport($e);
                 } elseif ($arrow instanceof SpiderArrow) {
                     $e->getLevel()->setBlock($e, Block::get(30));
                 } elseif ($arrow instanceof HealArrow) {
                     $damage = -$damage;
                 } elseif ($arrow instanceof PowerArrow) {
                     $damage = round($damage * rand(2, 3) / 2);
                 } else {
                     return;
                 }
                 $arrow->kill();
             }
         }
         $event->setDamage($damage);
     }
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:28,代码来源:ArrowAbility.php

示例8: onPvP

 public function onPvP(EntityDamageEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     if (!$ev instanceof EntityDamageByEntityEvent) {
         return;
     }
     if (!(($pl = $ev->getEntity()) instanceof Player && $ev->getDamager() instanceof Player)) {
         return;
     }
     $world = $pl->getLevel()->getName();
     if (!isset($this->wcfg[$world])) {
         return;
     }
     if ($this->wcfg[$world] !== false) {
         $sp = $pl->getLevel()->getSpawnLocation();
         $dist = $sp->distance($pl);
         if ($dist > $this->owner->getServer()->getSpawnRadius()) {
             return;
         }
     }
     $this->owner->msg($ev->getDamager(), mc::_("You are not allowed to do that here"));
     $ev->setCancelled();
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:25,代码来源:WpPvpMgr.php

示例9: onHurt

 public function onHurt(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         if ($event->getDamager()->getInventory()->getItemInHand()->getId() === 276) {
             $event->getEntity()->addEffect(Effect::getEffect($this->getConfig()->get("DiamondSwordEffect"))->setAmplifier($this->getConfig()->get("DiamondSwordAmp"))->setDuration($this->getConfig()->get("DiamondSwordTime"))->setVisible(false));
         }
     }
 }
开发者ID:xHFx,项目名称:SwordEffects,代码行数:8,代码来源:Main.php

示例10: factionPVP

 public function factionPVP(EntityDamageEvent $factionDamage)
 {
     if ($factionDamage instanceof EntityDamageByEntityEvent) {
         if (!$factionDamage->getEntity() instanceof Player or !$factionDamage->getDamager() instanceof Player) {
             return true;
         }
         if (!$this->plugin->getSession($factionDamage->getEntity()->getPlayer())->inFaction() or !$this->plugin->getSession($factionDamage->getDamager()->getPlayer())) {
             return true;
         }
         if ($factionDamage->getEntity() instanceof Player and $factionDamage->getDamager() instanceof Player) {
             $player1 = $factionDamage->getEntity()->getPlayer()->getName();
             $player2 = $factionDamage->getDamager()->getPlayer()->getName();
             if ($this->plugin->sameFaction($player1, $player2) == true) {
                 $factionDamage->setCancelled(true);
             }
         }
     }
 }
开发者ID:JiangsNetworkAlpha,项目名称:zzzzzz-FACTIONS,代码行数:18,代码来源:FactionListener.php

示例11: onEntityDamageByEntity

 public function onEntityDamageByEntity(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         $victim = $event->getEntity();
         $attacker = $event->getDamager();
         $this->debug->onDebug('Damage denied');
         $event->setCancelled(true);
     }
 }
开发者ID:100henrik100,项目名称:Minecraft-Pocket-Edition,代码行数:9,代码来源:antipvp.php

示例12: onEntityDamage

 public function onEntityDamage(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         $damager = $event->getDamager();
         if ($damager instanceof Player && $this->isPlayer($damager)) {
             $damager->sendTip(TextFormat::RED . "You cannot damage players while in fly mode!");
             $event->setCancelled(true);
         }
     }
 }
开发者ID:Ad5001,项目名称:SafeFly,代码行数:10,代码来源:Main.php

示例13: onEntityDamage

 /** 
  * @param EntityDamageEvent $event 
  * @priority MONITOR
  * @ignoreCancelled true
  */
 public function onEntityDamage(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         if (($damager = $event->getDamager()) instanceof Player and ($entity = $event->getEntity()) instanceof Player) {
             switch ($this->plugin->getTouchMode($damager)) {
                 case SkinTools::GIVE:
                     $event->setCancelled(true);
                     $this->plugin->setStolenSkin($entity, $damager);
                     $entity->sendMessage(TextFormat::GREEN . $damager->getName() . " gave you their skin!");
                     $damager->sendMessage(TextFormat::GREEN . $entity->getName() . " has your skin now!");
                     break;
                 case SkinTools::STEAL:
                     $event->setCancelled(true);
                     $this->plugin->setStolenSkin($damager, $entity);
                     $event->getDamager()->sendMessage(TextFormat::GREEN . "You got " . $entity->getName() . "'s skin.");
                     break;
             }
         }
     }
 }
开发者ID:NameNoOne100,项目名称:PocketMine-Plugins,代码行数:25,代码来源:SkinToolsListener.php

示例14: onEntityDamageByEntity

 public function onEntityDamageByEntity(ede $e)
 {
     if ($e instanceof edbee) {
         $p = $e->getEntity();
         $d = $e->getDamager();
         if ($this->isOni($d) and $this->isHuman($p)) {
             $this->Tatch($p, $d);
         } else {
             $e->setCancelled();
         }
     }
 }
开发者ID:moinngmg,项目名称:Onigo,代码行数:12,代码来源:Main.php

示例15: onDamage

 public function onDamage(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         if ($this->purgeStarted) {
             return;
         }
         if ($event->getEntity() instanceof Player and $event->getDamager() instanceof Player) {
             // TODO 제한시간 출력
             $event->setCancelled();
         }
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:12,代码来源:Purge.php


注:本文中的pocketmine\event\entity\EntityDamageEvent::getDamager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。