本文整理汇总了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();
}
}
}
}
示例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);
}
}
示例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();
}
}
}
示例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]);
}
}
示例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);
}
}
}
}
示例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();
}
}
}
示例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);
}
}
示例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();
}
示例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));
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}
}
}
示例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();
}
}
}
示例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();
}
}
}