當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityDamageEvent::getPlayer方法代碼示例

本文整理匯總了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;
 }
開發者ID:TheGoldenPickle,項目名稱:PartyPlugin,代碼行數:17,代碼來源:Main.php

示例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);
             }
         }
     }
 }
開發者ID:Jackboy320,項目名稱:MTeamPvP,代碼行數:14,代碼來源:TeamPvP.php

示例3: cancelFallDamage

 public function cancelFallDamage(EntityDamageEvent $e)
 {
     if ($this->isInArena($e->getPlayer())) {
         $causeID = $e->getCause();
         if ($causeID === 4) {
             $e->setCancelled();
         }
     }
 }
開發者ID:andrewnoelcasper,項目名稱:Falcon-Spleef,代碼行數:9,代碼來源:index.php


注:本文中的pocketmine\event\entity\EntityDamageEvent::getPlayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。