public function targetOption(Player $player, $distance) { return $player->spawned && $player->isAlive() && !$player->closed && $player->isSurvival() && $distance <= 81; }
/** * @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); } }
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); } }
public function targetOption(Player $player, $distance) { return $player->spawned && $player->isAlive() && !$player->closed && $player->getInventory()->getItemInHand()->getId() == Item::WHEAT && $distance <= 49; }
/** * @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; } } } }