diff --git a/changelog.txt b/changelog.txt index 1f7a4850..e10627ff 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ #Additions - added changelog +- added SocketManager which acts like a webserver you can connect to and interact with ManiaControl - added "//removerights login" command - added new EchoManager which handles Interactions between different Controllers - It is possible to send an Echo command via the Method sendEcho, as message Parameter strings, objects or arrays can get used @@ -10,7 +11,9 @@ - On sending an Echo Message from another controller you need to provide an string to the dedicated method or an json_encoded array or object - 4 Echos are Implemented by ManiaControl (ManiaControl.Restart, ManiaControl.AuthenticationManager.GrandLevel, ManiaControl.AuthenticationManager.RevokeLevel, ManiaControl.PlayerManager.WarnPlayer) - added Method getServerLoginByIndex to Server object +- added Parameter withoutBots to getPlayerCount (default on true) - added some missing PHP Docs +- added some depency libraries as they are used by the Socket Handler - updated some depency libraries #Bug Fixes diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 1752a3c2..6c59f23f 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -382,15 +382,24 @@ class PlayerManager implements CallbackListener, TimerListener, EchoListener { * Get the count of all Players * * @param bool $withoutSpectators + * @param bool $withoutBots * @return int */ - public function getPlayerCount($withoutSpectators = true) { - if (!$withoutSpectators) { - return count($this->players); - } + public function getPlayerCount($withoutSpectators = true, $withoutBots = true) { $count = 0; foreach ($this->players as $player) { - if (!$player->isSpectator) { + $valid = true; + if ($withoutSpectators) { + if ($player->isSpectator) { + $valid = false; + } + } + if ($withoutBots) { + if ($player->isFakePlayer()) { + $valid = false; + } + } + if ($valid) { $count++; } }