From 0b02f6330984cf876294b039fadff207e14d396e Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 26 Jun 2015 13:25:29 +0200 Subject: [PATCH] added getSpectators to PlayerManager --- changelog.txt | 3 ++- core/Communication/usage_documentation.txt | 1 + core/Players/PlayerManager.php | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 85db00dc..b62ce875 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,7 +12,8 @@ - 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 to PlayerManager's Method PlayerManager the Parameter "withoutBots" (default on true) +- added Method getSpectators() in PlayerManager - added some missing PHP Docs - added some depency libraries as they are used by the Socket Handler - updated some depency libraries diff --git a/core/Communication/usage_documentation.txt b/core/Communication/usage_documentation.txt index fccbc9c5..3dc28b14 100644 --- a/core/Communication/usage_documentation.txt +++ b/core/Communication/usage_documentation.txt @@ -8,6 +8,7 @@ There the following settings are existing: For the description of the available implemented communcation Methods check the CommunicationMethods interface. +If you need methods which are not implemented, or additional Parameters, feel free to contact us. Sample ManiaControl Implementation (for ManiaControl to ManiaControl connections) diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index d697177c..568d039b 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -535,6 +535,22 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis return $this->players; } + /** + * Get a List of Spectators + * + * @return Player[] + */ + public function getSpectators() { + $spectators = array(); + foreach ($this->players as $player) { + if ($player->isSpectator) { + $spectators[] = $player; + } + } + + return $spectators; + } + /** * Get the count of all spectators *