コード例 #1
1
ファイル: Monster.php プロジェクト: rilex04/EntityManager
 public function targetOption(Player $player, $distance)
 {
     return $player->spawned && $player->isAlive() && !$player->closed && $player->isSurvival() && $distance <= 81;
 }
コード例 #2
0
 /**
  * @param Player $player
  */
 public function spawnTo(Player $player)
 {
     if ($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevel() === $this->level and $player->canSee($this) and !$this->isSpectator()) {
         parent::spawnTo($player);
     }
 }
コード例 #3
0
ファイル: GameLevelManager.php プロジェクト: robozeri/SG
 public function handlePlayerLeaveTheGame(Player $player)
 {
     if ($player != null) {
         foreach ($this->plugin->gameLevelManager->levels as &$lv) {
             if ($lv instanceof GameLevelModel) {
                 if (count($lv->joinedPlayers) > 0) {
                     if (isset($lv->joinedPlayers[$player->getName()])) {
                         unset($lv->joinedPlayers[$player->getName()]);
                         $this->plugin->log("[HG]gamelevelmanager handlePlayerLeaveTheGame: " . $player->getName() . " |  remains: " . count($lv->joinedPlayers));
                         if (count($lv->joinedPlayers) === 0 || count($lv->joinedPlayers) === 1) {
                             if ($lv->currentStep === GameLevelModel::STATUS_MAP_SELECTION || $lv->currentStep === GameLevelModel::STEP_WAITING) {
                                 $this->plugin->openGate($lv);
                                 $this->plugin->log("[HG] No player left in portal - reset portal state | " . $lv->type . " | " . $lv->name);
                                 $lv->joinDownCounter = $lv->joinDownCounterReset;
                                 $lv->status = GameLevelModel::STATUS_AVAILABLE;
                                 $lv->currentStep = GameLevelModel::STEP_JOINING;
                             }
                         }
                         // @FIXE ME remove votes
                         foreach ($this->plugin->arenaManager->arenas as &$arena) {
                             if ($arena instanceof MapArenaModel) {
                                 if (isset($arena->votedPlayers[$player->getName()])) {
                                     unset($arena->votedPlayers[$player->getName()]);
                                     if ($arena->vote >= 1) {
                                         $arena->vote--;
                                     }
                                     break;
                                 }
                             }
                         }
                     }
                     if (!empty($lv->currentMap)) {
                         if (isset($lv->currentMap->livePlayers[$player->getName()])) {
                             unset($lv->currentMap->livePlayers[$player->getName()]);
                             $recordloss = new HungerGamesRecordLossTask($this->plugin, $lv, $player->getName());
                             $this->plugin->getServer()->getScheduler()->scheduleDelayedTask($recordloss, 30);
                         }
                         if (isset($lv->currentMap->joinedPlayers[$player->getName()])) {
                             unset($lv->currentMap->joinedPlayers[$player->getName()]);
                         }
                         if (isset($lv->currentMap->votedPlayers[$player->getName()])) {
                             unset($lv->currentMap->votedPlayers[$player->getName()]);
                         }
                         break;
                     }
                 }
             }
         }
     }
     // @FIXME
     if (!empty($player->getInventory() && $player->isAlive())) {
         HungerGameKit::clearAllInventories($player);
     }
 }
コード例 #4
0
ファイル: Cow.php プロジェクト: rilex04/EntityManager
 public function targetOption(Player $player, $distance)
 {
     return $player->spawned && $player->isAlive() && !$player->closed && $player->getInventory()->getItemInHand()->getId() == Item::WHEAT && $distance <= 49;
 }
コード例 #5
0
ファイル: SAPI.php プロジェクト: gitter-badger/Development-1
 /**
  * @param Player $level
  * @return Player $killer
  */
 public function getKiller(Player $player)
 {
     if ($player->isOnline() && !$player->isAlive()) {
         $cause = $player->getLastDamageCause();
         if ($cause instanceof EntityDamageByEntityEvent) {
             $killer = $cause->getDamager();
             if ($killer->isOnline() && $killer instanceof Player) {
                 return $killer;
             }
         }
     }
 }