mapqueue fix, begin mapactions class
This commit is contained in:
parent
274384767c
commit
a51d5423a3
46
application/core/Maps/MapActions.php
Normal file
46
application/core/Maps/MapActions.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Map Actions Class
|
||||||
|
*
|
||||||
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
|
* @copyright 2014 ManiaControl Team
|
||||||
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
|
*/
|
||||||
|
namespace ManiaControl\Maps;
|
||||||
|
|
||||||
|
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
||||||
|
|
||||||
|
class MapActions {
|
||||||
|
/*
|
||||||
|
* Private Properties
|
||||||
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a MapActions Instance
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
*/
|
||||||
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
|
$this->maniaControl = $maniaControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skips the current Map
|
||||||
|
*/
|
||||||
|
public function skipMap() {
|
||||||
|
//Force a EndMap on the MapQueue to set the next Map
|
||||||
|
$this->maniaControl->mapManager->mapQueue->endMap(null);
|
||||||
|
|
||||||
|
//ignore EndMap on MapQueue
|
||||||
|
$this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange();
|
||||||
|
|
||||||
|
//Switch The Map
|
||||||
|
try {
|
||||||
|
$this->maniaControl->client->nextMap();
|
||||||
|
} catch (ChangeInProgressException $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -192,10 +192,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
$this->maniaControl->client->nextMap();
|
$this->maniaControl->mapManager->mapActions->skipMap();
|
||||||
} catch (ChangeInProgressException $e) {
|
|
||||||
}
|
|
||||||
$message = '$<' . $player->nickname . '$> skipped the current Map!';
|
$message = '$<' . $player->nickname . '$> skipped the current Map!';
|
||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
$this->maniaControl->log($message, true);
|
$this->maniaControl->log($message, true);
|
||||||
|
@ -327,7 +327,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
if (isset($queuedMaps[$map->uid])) {
|
if (isset($queuedMaps[$map->uid])) {
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$mapFrame->add($label);
|
$mapFrame->add($label);
|
||||||
$label->setX($width / 2 - 15);
|
$label->setX($width / 2 - 13);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1.5);
|
$label->setTextSize(1.5);
|
||||||
@ -595,6 +595,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->maniaControl->mapManager->removeMap($player, $mapUid);
|
$this->maniaControl->mapManager->removeMap($player, $mapUid);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_SWITCH_MAP:
|
case self::ACTION_SWITCH_MAP:
|
||||||
|
//Don't queue on Map-Change
|
||||||
|
$this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange();
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->jumpToMapIdent($mapUid);
|
$this->maniaControl->client->jumpToMapIdent($mapUid);
|
||||||
} catch (MapNotFoundException $e) {
|
} catch (MapNotFoundException $e) {
|
||||||
@ -624,6 +626,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$self->maniaControl->chat->sendInformation('$sVote Successfully -> Map switched!');
|
$self->maniaControl->chat->sendInformation('$sVote Successfully -> Map switched!');
|
||||||
$votesPlugin->undefineVote('switchmap');
|
$votesPlugin->undefineVote('switchmap');
|
||||||
|
|
||||||
|
//Don't queue on Map-Change
|
||||||
|
$this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$self->maniaControl->client->JumpToMapIdent($map->uid);
|
$self->maniaControl->client->JumpToMapIdent($map->uid);
|
||||||
} catch (MapNotFoundException $e) {
|
} catch (MapNotFoundException $e) {
|
||||||
|
@ -54,6 +54,7 @@ class MapManager implements CallbackListener {
|
|||||||
public $mapList = null;
|
public $mapList = null;
|
||||||
public $mxList = null;
|
public $mxList = null;
|
||||||
public $mxManager = null;
|
public $mxManager = null;
|
||||||
|
public $mapActions = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
@ -82,6 +83,7 @@ class MapManager implements CallbackListener {
|
|||||||
$this->mxList = new ManiaExchangeList($this->maniaControl);
|
$this->mxList = new ManiaExchangeList($this->maniaControl);
|
||||||
$this->mapCommands = new MapCommands($maniaControl);
|
$this->mapCommands = new MapCommands($maniaControl);
|
||||||
$this->mapQueue = new MapQueue($this->maniaControl);
|
$this->mapQueue = new MapQueue($this->maniaControl);
|
||||||
|
$this->mapActions = new MapActions($maniaControl);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
||||||
|
@ -10,6 +10,7 @@ use ManiaControl\Commands\CommandListener;
|
|||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapQueue Class
|
* MapQueue Class
|
||||||
@ -42,6 +43,14 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
private $queuedMaps = array();
|
private $queuedMaps = array();
|
||||||
private $nextMap = null;
|
private $nextMap = null;
|
||||||
private $buffer = array();
|
private $buffer = array();
|
||||||
|
private $nextNoQueue = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't queue on the next MapChange
|
||||||
|
*/
|
||||||
|
public function dontQueueNextMapChange() {
|
||||||
|
$this->nextNoQueue = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server MapQueue
|
* Create a new server MapQueue
|
||||||
@ -291,7 +300,13 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
*
|
*
|
||||||
* @param Map $map
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function endMap(Map $map) {
|
public function endMap(Map $map = null) {
|
||||||
|
//Don't queue next map (for example on skip to map)
|
||||||
|
if($this->nextNoQueue){
|
||||||
|
$this->nextNoQueue = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->nextMap = null;
|
$this->nextMap = null;
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) {
|
||||||
|
|
||||||
@ -333,9 +348,13 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$map = $this->nextMap[1];
|
$map = $this->nextMap[1];
|
||||||
|
/** @var Map $map */
|
||||||
$this->maniaControl->chat->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
$this->maniaControl->chat->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
||||||
|
|
||||||
$this->maniaControl->client->chooseNextMap($map->fileName);
|
try{
|
||||||
|
$this->maniaControl->client->setNextMapIdent($map->uid);
|
||||||
|
}catch (NextMapException $e){
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -503,7 +503,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
case 'skipmap':
|
case 'skipmap':
|
||||||
case 'skip':
|
case 'skip':
|
||||||
case 'nextmap':
|
case 'nextmap':
|
||||||
$this->maniaControl->client->nextMap();
|
$this->maniaControl->mapManager->mapActions->skipMap();
|
||||||
$this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the map$f8f has been successfull!');
|
$this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the map$f8f has been successfull!');
|
||||||
break;
|
break;
|
||||||
case 'restartmap':
|
case 'restartmap':
|
||||||
|
Loading…
Reference in New Issue
Block a user