Some minor fixes on Player and Plugin Manager

This commit is contained in:
kremsy 2017-05-21 20:30:26 +02:00
parent 5a248c42c2
commit e072024ce5
3 changed files with 14 additions and 10 deletions

View File

@ -112,20 +112,20 @@ class CommunicationManager implements CallbackListener, UsageInformationAble {
/** /**
* Register a new Communication Listener * Register a new Communication Listener
* *
* @param string $callbackName * @param string $communicationName
* @param CommunicationListener $listener * @param CommunicationListener $listener
* @param string $method * @param string $method
* @return bool * @return bool
*/ */
public function registerCommunicationListener($echoName, CommunicationListener $listener, $method) { public function registerCommunicationListener($communicationName, CommunicationListener $listener, $method) {
if (!Listening::checkValidCallback($listener, $method)) { if (!Listening::checkValidCallback($listener, $method)) {
$listenerClass = get_class($listener); $listenerClass = get_class($listener);
trigger_error("Given Listener '{$listenerClass}' can't handle Callback '{$echoName}': No callable Method '{$method}'!"); trigger_error("Given Listener '{$listenerClass}' can't handle Callback '{$communicationName}': No callable Method '{$method}'!");
return false; return false;
} }
if (!array_key_exists($echoName, $this->communicationListenings)) { if (!array_key_exists($communicationName, $this->communicationListenings)) {
$this->communicationListenings[$echoName] = new Listening($listener, $method); $this->communicationListenings[$communicationName] = new Listening($listener, $method);
} else { } else {
//TODO say which is already listening and other stuff //TODO say which is already listening and other stuff
trigger_error("Only one Listener can listen on a specific Communication Message"); trigger_error("Only one Listener can listen on a specific Communication Message");
@ -173,10 +173,10 @@ class CommunicationManager implements CallbackListener, UsageInformationAble {
*/ */
private function removeCommunicationListener(array &$listeningsArray, CommunicationListener $listener) { private function removeCommunicationListener(array &$listeningsArray, CommunicationListener $listener) {
$removed = false; $removed = false;
foreach ($listeningsArray as &$listening) {
foreach ($listeningsArray as $key => &$listening) {
if($listening->listener === $listener){ if($listening->listener === $listener){
unset($listening); unset($listeningsArray[$key]);
$removed = true;
} }
} }
return $removed; return $removed;

View File

@ -589,7 +589,7 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
$players = array(); $players = array();
foreach ($this->players as $player) { foreach ($this->players as $player) {
if (!$player->isSpectator) { if (!$player->isSpectator) {
$players[] = $players; $players[] = $player;
} }
} }

View File

@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\EchoListener; use ManiaControl\Callbacks\EchoListener;
use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\Files\AsyncHttpRequest;
use ManiaControl\Files\FileUtil; use ManiaControl\Files\FileUtil;
use ManiaControl\Logger; use ManiaControl\Logger;
@ -190,6 +191,9 @@ class PluginManager {
if($plugin instanceof SidebarMenuEntryListener){ if($plugin instanceof SidebarMenuEntryListener){
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->deleteMenuEntries($plugin); $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->deleteMenuEntries($plugin);
} }
if($plugin instanceof CommunicationListener){
$this->maniaControl->getCommunicationManager()->unregisterCommunicationListener($plugin);
}
$this->savePluginStatus($pluginClass, false); $this->savePluginStatus($pluginClass, false);