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
*
* @param string $callbackName
* @param string $communicationName
* @param CommunicationListener $listener
* @param string $method
* @return bool
*/
public function registerCommunicationListener($echoName, CommunicationListener $listener, $method) {
public function registerCommunicationListener($communicationName, CommunicationListener $listener, $method) {
if (!Listening::checkValidCallback($listener, $method)) {
$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;
}
if (!array_key_exists($echoName, $this->communicationListenings)) {
$this->communicationListenings[$echoName] = new Listening($listener, $method);
if (!array_key_exists($communicationName, $this->communicationListenings)) {
$this->communicationListenings[$communicationName] = new Listening($listener, $method);
} else {
//TODO say which is already listening and other stuff
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) {
$removed = false;
foreach ($listeningsArray as &$listening) {
foreach ($listeningsArray as $key => &$listening) {
if($listening->listener === $listener){
unset($listening);
$removed = true;
unset($listeningsArray[$key]);
}
}
return $removed;

View File

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

View File

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