vote plugin, possability to react on trigger events, now built in only for map ralated votes

This commit is contained in:
kremsy
2014-07-04 11:34:17 +02:00
parent 82f639be46
commit 2709df4d7e
3 changed files with 78 additions and 10 deletions

View File

@ -158,6 +158,26 @@ class CallbackManager {
return $this->removeCallbackListener($this->callbackListenings, $listener);
}
//TODO better name (used only in customvotesPlugin)
/**
* Unregister a single Callback Listening from an Callback Listener
*
* @param String $callbackName
* @param CallbackListener $listener
* @return bool
*/
public function unregisterCallbackListening($callbackName, CallbackListener $listener){
foreach($this->callbackListenings as &$listenings){
foreach ($listenings as $key => &$listening) {
if($key == $callbackName && $listening->listener === $listener){
unset($listenings[$key]);
return true;
}
}
}
return false;
}
/**
* Remove the Callback Listener from the given Listeners Array
*

View File

@ -622,10 +622,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$message = $player->getEscapedNickname() . '$s started a vote to switch to ' . $map->getEscapedName() . '!';
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message);
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message)->setStopCallback(Callbacks::ENDMAP);
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) {
// TODO: $result isn't used -> bug? does it skip even if vote is not successful?
$votesPlugin->undefineVote('switchmap');
//Don't queue on Map-Change