coding & phpdoc improvements continued
This commit is contained in:
parent
9e016cc770
commit
c284feb843
@ -671,7 +671,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
public function updateWidget() {
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
foreach ($players as $player) {
|
||||
/** @var Player $player */
|
||||
$currentPage = $player->getCache($this, self::CACHE_CURRENT_PAGE);
|
||||
if ($currentPage !== null) {
|
||||
$this->showMapList($player, null, $currentPage);
|
||||
|
@ -175,8 +175,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$pageFrame = null;
|
||||
|
||||
foreach ($players as $listPlayer) {
|
||||
/** @var Player $listPlayer * */
|
||||
|
||||
if ($i % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
|
@ -40,6 +40,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
public $playerDetailed = null;
|
||||
public $playerList = null;
|
||||
public $adminLists = null;
|
||||
/** @var Player[] $players */
|
||||
public $players = array();
|
||||
|
||||
/*
|
||||
@ -296,10 +297,12 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
* @return int
|
||||
*/
|
||||
public function getPlayerCount($withoutSpectators = true) {
|
||||
if (!$withoutSpectators) {
|
||||
return count($this->players);
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($this->players as $player) {
|
||||
/** @var Player $player */
|
||||
if (!$player->isSpectator || !$withoutSpectators) {
|
||||
if (!$player->isSpectator) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
@ -413,7 +416,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
/**
|
||||
* Get all Players
|
||||
*
|
||||
* @return array
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getPlayers() {
|
||||
return $this->players;
|
||||
@ -427,7 +430,6 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
public function getSpectatorCount() {
|
||||
$count = 0;
|
||||
foreach ($this->players as $player) {
|
||||
/** @var Player $player */
|
||||
if ($player->isSpectator) {
|
||||
$count++;
|
||||
}
|
||||
@ -436,15 +438,14 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Player by his index
|
||||
* Gets a Player by his Index
|
||||
*
|
||||
* @param int $index
|
||||
* @param bool $connectedPlayersOnly
|
||||
* @return Player|null
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayerByIndex($index, $connectedPlayersOnly = false) {
|
||||
foreach ($this->players as $player) {
|
||||
/** @var Player $player */
|
||||
if ($player->index == $index) {
|
||||
return $player;
|
||||
}
|
||||
|
@ -29,7 +29,9 @@ class PluginManager {
|
||||
private $maniaControl = null;
|
||||
private $pluginMenu = null;
|
||||
private $pluginInstallMenu = null;
|
||||
/** @var Plugin[] $activePlugins */
|
||||
private $activePlugins = array();
|
||||
/** @var string[] $pluginClasses */
|
||||
private $pluginClasses = array();
|
||||
|
||||
/**
|
||||
|
@ -215,8 +215,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
public function each5Seconds() {
|
||||
// Empty shutdown
|
||||
if ($this->serverShutdownEmpty) {
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
if (count($players) <= 0) {
|
||||
if ($this->maniaControl->playerManager->getPlayerCount(false) <= 0) {
|
||||
$this->shutdownServer('empty');
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class StatisticCollector implements CallbackListener {
|
||||
*/
|
||||
public function onEndMap(array $callback) {
|
||||
//Check for Minimum PlayerCount
|
||||
if (count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
if ($this->maniaControl->playerManager->getPlayerCount() < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,13 +149,13 @@ class StatisticCollector implements CallbackListener {
|
||||
*/
|
||||
public function handleCallbacks(array $callback) {
|
||||
//TODO survivals
|
||||
//Check if Stat Collecting is enabled
|
||||
// Check if Stat Collecting is enabled
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Check for Minimum PlayerCount
|
||||
if (count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
// Check for Minimum PlayerCount
|
||||
if ($this->maniaControl->playerManager->getPlayerCount() < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
// No update available
|
||||
return;
|
||||
}
|
||||
if (count($this->maniaControl->playerManager->getPlayers()) > 0) {
|
||||
if ($this->maniaControl->playerManager->getPlayerCount(false) > 0) {
|
||||
// Server not empty
|
||||
return;
|
||||
}
|
||||
|
@ -146,10 +146,9 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTarget($login) {
|
||||
/** @var Player $player */
|
||||
$player = null;
|
||||
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||
if ($login == $player && $login == $player->login || $login == $player->pid || $login == $player->nickname) {
|
||||
if ($login == $player || $login == $player->login || $login == $player->pid || $login == $player->nickname) {
|
||||
return $player->nickname;
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
return null;
|
||||
}
|
||||
|
||||
if (count($this->maniaControl->playerManager->getPlayers()) == 0) {
|
||||
if ($this->maniaControl->playerManager->getPlayerCount(false) <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -326,7 +326,6 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
}
|
||||
$playerInfo = array();
|
||||
foreach ($players as $player) {
|
||||
/** @var Player $player */
|
||||
array_push($playerInfo, array('Login' => $player->login, 'IsSpec' => $player->isSpectator));
|
||||
}
|
||||
return $playerInfo;
|
||||
|
@ -362,7 +362,6 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$properties['getvotesonly'] = false;
|
||||
$properties['playerlogins'] = array();
|
||||
foreach ($this->maniaControl->playerManager->getPlayers() as $loopPlayer) {
|
||||
/** @var Player $loopPlayer */
|
||||
$properties['playerlogins'][] = $loopPlayer->login;
|
||||
}
|
||||
} else {
|
||||
|
@ -400,7 +400,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
$this->resetRanks();
|
||||
|
||||
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||
/** @var Player $player */
|
||||
if ($player->isFakePlayer()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -306,25 +306,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$backgroundQuad->setSize($width, $height);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
|
||||
|
||||
$maxSpectators = $this->maniaControl->client->getMaxSpectators();
|
||||
|
||||
$serverName = $this->maniaControl->client->getServerName();
|
||||
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
$playerCount = 0;
|
||||
$spectatorCount = 0;
|
||||
/**
|
||||
* @var Player $player
|
||||
*/
|
||||
foreach ($players as $player) {
|
||||
if ($player->isSpectator) {
|
||||
$spectatorCount++;
|
||||
} else {
|
||||
$playerCount++;
|
||||
}
|
||||
}
|
||||
$playerCount = $this->maniaControl->playerManager->getPlayerCount(true);
|
||||
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
|
||||
|
||||
$spectatorCount = $this->maniaControl->playerManager->getSpectatorCount();
|
||||
$maxSpectators = $this->maniaControl->client->getMaxSpectators();
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
|
Loading…
Reference in New Issue
Block a user