本文整理匯總了PHP中pocketmine\event\entity\EntityDamageEvent::getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityDamageEvent::getPlayer方法的具體用法?PHP EntityDamageEvent::getPlayer怎麽用?PHP EntityDamageEvent::getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\event\entity\EntityDamageEvent
的用法示例。
在下文中一共展示了EntityDamageEvent::getPlayer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onDamageByPlayer
public function onDamageByPlayer(EntityDamageEvent $ev)
{
$cause = $ev->getCause();
switch ($cause) {
case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
$atkr = $ev->getDamager();
$player = $ev->getEntity();
$pl = $ev->getPlayer();
if ($atkr instanceof Player and $player instanceof Player) {
if ($this->inParty($player, $atkr->getName())) {
$ev->setCancelled();
$atkr->sendMessage(TextFormat::RED . "{$pl} is in your party!");
}
}
}
break;
}
示例2: onEntityDamage
public function onEntityDamage(EntityDamageEvent $event)
{
if ($event instanceof EntityDamageByEntityEvent) {
if ($event->getEntity() instanceof Player) {
if ($this->isFriend($event->getDamager()->getName(), $event->getEntity()->getName()) && $this->gameStarted == true) {
$event->setCancelled(true);
$event->getDamager()->sendMessage(str_replace("{player}", $event->getPlayer()->getName(), $this->yml["hit_same_team_message"]));
}
if ($this->isFriend($event->getDamager()->getName(), $event->getEntity()->getName())) {
$event->setCancelled(true);
}
}
}
}
示例3: cancelFallDamage
public function cancelFallDamage(EntityDamageEvent $e)
{
if ($this->isInArena($e->getPlayer())) {
$causeID = $e->getCause();
if ($causeID === 4) {
$e->setCancelled();
}
}
}