- moved map begin+end callbacks to map manager
- callback manager cleanup
This commit is contained in:
parent
ff9c21a8af
commit
71ab8764df
@ -17,9 +17,6 @@ class CallbackManager {
|
|||||||
const CB_ONINIT = 'ManiaControl.OnInit';
|
const CB_ONINIT = 'ManiaControl.OnInit';
|
||||||
const CB_AFTERINIT = 'ManiaControl.AfterInit';
|
const CB_AFTERINIT = 'ManiaControl.AfterInit';
|
||||||
const CB_ONSHUTDOWN = 'ManiaControl.OnShutdown';
|
const CB_ONSHUTDOWN = 'ManiaControl.OnShutdown';
|
||||||
const CB_CLIENTUPDATED = 'ManiaControl.ClientUpdated';
|
|
||||||
const CB_BEGINMAP = 'ManiaControl.BeginMap';
|
|
||||||
const CB_ENDMAP = 'ManiaControl.EndMap';
|
|
||||||
|
|
||||||
// ManiaPlanet callbacks
|
// ManiaPlanet callbacks
|
||||||
const CB_MP_SERVERSTART = 'ManiaPlanet.ServerStart';
|
const CB_MP_SERVERSTART = 'ManiaPlanet.ServerStart';
|
||||||
@ -52,11 +49,6 @@ class CallbackManager {
|
|||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $callbackListeners = array();
|
private $callbackListeners = array();
|
||||||
private $scriptCallbackListener = array();
|
private $scriptCallbackListener = array();
|
||||||
private $last1Second = -1;
|
|
||||||
private $last5Second = -1;
|
|
||||||
private $last1Minute = -1;
|
|
||||||
private $mapEnded = false;
|
|
||||||
private $mapBegan = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Callbacks Manager
|
* Construct a new Callbacks Manager
|
||||||
@ -65,10 +57,6 @@ class CallbackManager {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
$this->last1Second = time();
|
|
||||||
$this->last5Second = time();
|
|
||||||
$this->last1Minute = time();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,29 +188,23 @@ class CallbackManager {
|
|||||||
// Handle callbacks
|
// Handle callbacks
|
||||||
foreach($callbacks as $callback) {
|
foreach($callbacks as $callback) {
|
||||||
$callbackName = $callback[0];
|
$callbackName = $callback[0];
|
||||||
switch($callbackName) {
|
switch ($callbackName) {
|
||||||
case 'ManiaPlanet.BeginMap':
|
case 'ManiaPlanet.BeginMap':
|
||||||
if (!$this->mapBegan) {
|
$this->maniaControl->mapManager->handleBeginMap($callback);
|
||||||
$this->triggerCallback(self::CB_BEGINMAP, $callback);
|
$this->triggerCallback($callbackName, $callback);
|
||||||
$this->mapBegan = true;
|
|
||||||
$this->mapEnded = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'ManiaPlanet.EndMatch': //TODO temporary fix
|
case 'ManiaPlanet.EndMatch': //TODO temporary fix
|
||||||
case 'ManiaPlanet.EndMap':
|
case 'ManiaPlanet.EndMap':
|
||||||
if (!$this->mapEnded) {
|
$this->maniaControl->mapManager->handleEndMap($callback);
|
||||||
$this->triggerCallback(self::CB_ENDMAP, $callback);
|
$this->triggerCallback($callbackName, $callback);
|
||||||
$this->mapEnded = true;
|
|
||||||
$this->mapBegan = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case self::CB_MP_MODESCRIPTCALLBACK:
|
case self::CB_MP_MODESCRIPTCALLBACK:
|
||||||
$this->handleScriptCallback($callback);
|
$this->handleScriptCallback($callback);
|
||||||
$this->triggerCallback(self::CB_MP_MODESCRIPTCALLBACK, $callback);
|
$this->triggerCallback($callbackName, $callback);
|
||||||
break;
|
break;
|
||||||
case self::CB_MP_MODESCRIPTCALLBACKARRAY:
|
case self::CB_MP_MODESCRIPTCALLBACKARRAY:
|
||||||
$this->handleScriptCallback($callback);
|
$this->handleScriptCallback($callback);
|
||||||
$this->triggerCallback(self::CB_MP_MODESCRIPTCALLBACKARRAY, $callback);
|
$this->triggerCallback($callbackName, $callback);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->triggerCallback($callbackName, $callback);
|
$this->triggerCallback($callbackName, $callback);
|
||||||
@ -242,21 +224,13 @@ class CallbackManager {
|
|||||||
switch($scriptCallbackName) {
|
switch($scriptCallbackName) {
|
||||||
case 'BeginMap':
|
case 'BeginMap':
|
||||||
case 'LibXmlRpc_BeginMap':
|
case 'LibXmlRpc_BeginMap':
|
||||||
|
$this->maniaControl->mapManager->handleScriptBeginMap($callback);
|
||||||
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
||||||
if (!$this->mapBegan) {
|
|
||||||
$this->triggerCallback(self::CB_BEGINMAP, $callback);
|
|
||||||
$this->mapBegan = true;
|
|
||||||
$this->mapEnded = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'EndMap':
|
case 'EndMap':
|
||||||
case 'LibXmlRpc_EndMap':
|
case 'LibXmlRpc_EndMap':
|
||||||
|
$this->maniaControl->mapManager->handleScriptEndMap($callback);
|
||||||
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
||||||
if (!$this->mapEnded) {
|
|
||||||
$this->triggerCallback(self::CB_ENDMAP, $callback);
|
|
||||||
$this->mapEnded = true;
|
|
||||||
$this->mapBegan = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
||||||
|
@ -21,11 +21,12 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
|||||||
* @author kremsy & steeffeen
|
* @author kremsy & steeffeen
|
||||||
*/
|
*/
|
||||||
class MapManager implements CallbackListener {
|
class MapManager implements CallbackListener {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const TABLE_MAPS = 'mc_maps';
|
const TABLE_MAPS = 'mc_maps';
|
||||||
const CB_BEGINMAP = 'MapManager.BeginMap';
|
const CB_BEGINMAP = 'MapManager.BeginMap';
|
||||||
|
const CB_ENDMAP = 'MapManager.EndMap';
|
||||||
const CB_MAPS_UPDATED = 'MapManager.MapsUpdated';
|
const CB_MAPS_UPDATED = 'MapManager.MapsUpdated';
|
||||||
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
|
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
|
||||||
const SETTING_PERMISSION_ADD_MAP = 'Add Maps';
|
const SETTING_PERMISSION_ADD_MAP = 'Add Maps';
|
||||||
@ -35,7 +36,7 @@ class MapManager implements CallbackListener {
|
|||||||
const SETTING_PERMISSION_SKIP_MAP = 'Skip Map';
|
const SETTING_PERMISSION_SKIP_MAP = 'Skip Map';
|
||||||
const SETTING_PERMISSION_RESTART_MAP = 'Restart Map';
|
const SETTING_PERMISSION_RESTART_MAP = 'Restart Map';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Public Properties
|
* Public Properties
|
||||||
*/
|
*/
|
||||||
public $mapQueue = null;
|
public $mapQueue = null;
|
||||||
@ -44,16 +45,18 @@ class MapManager implements CallbackListener {
|
|||||||
public $mxList = null;
|
public $mxList = null;
|
||||||
public $mxManager = null;
|
public $mxManager = null;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $maps = array();
|
private $maps = array();
|
||||||
/** @var Map $currentMap */
|
/** @var Map $currentMap */
|
||||||
private $currentMap = null;
|
private $currentMap = null;
|
||||||
|
private $mapEnded = false;
|
||||||
|
private $mapBegan = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct map manager
|
* Construct a new Map Manager
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
*/
|
*/
|
||||||
@ -70,10 +73,9 @@ class MapManager implements CallbackListener {
|
|||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_BEGINMAP, $this, 'handleBeginMap');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
|
||||||
|
|
||||||
//Define Rights
|
// Define Rights
|
||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_ADD_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_ADD_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_REMOVE_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_REMOVE_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUFFLE_MAPS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUFFLE_MAPS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
@ -83,7 +85,7 @@ class MapManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize necessary database tables
|
* Initialize necessary Database Tables
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -242,7 +244,6 @@ class MapManager implements CallbackListener {
|
|||||||
unset($this->maps[$uid]);
|
unset($this->maps[$uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restructures the Maplist
|
* Restructures the Maplist
|
||||||
*/
|
*/
|
||||||
@ -368,23 +369,24 @@ class MapManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch current Map
|
* Freshly fetch current Map
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return Map
|
||||||
*/
|
*/
|
||||||
private function fetchCurrentMap() {
|
public function fetchCurrentMap() {
|
||||||
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
|
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
|
||||||
|
|
||||||
if (array_key_exists($rpcMap->uId, $this->maps)) {
|
if (array_key_exists($rpcMap->uId, $this->maps)) {
|
||||||
$this->currentMap = $this->maps[$rpcMap->uId];
|
$this->currentMap = $this->maps[$rpcMap->uId];
|
||||||
|
// TODO: why set numbers? shouldn't they be set already?
|
||||||
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
|
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
|
||||||
$this->currentMap->nbLaps = $rpcMap->nbLaps;
|
$this->currentMap->nbLaps = $rpcMap->nbLaps;
|
||||||
return true;
|
return $this->currentMap;
|
||||||
}
|
}
|
||||||
$map = $this->initializeMap($rpcMap);
|
|
||||||
$this->maps[$map->uid] = $map;
|
$this->currentMap = $this->initializeMap($rpcMap);
|
||||||
$this->currentMap = $map;
|
$this->maps[$this->currentMap->uid] = $this->currentMap;
|
||||||
return true;
|
return $this->currentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,26 +431,73 @@ class MapManager implements CallbackListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleBeginMap(array $callback) {
|
public function handleBeginMap(array $callback) {
|
||||||
if (!isset($callback[1][0]["UId"])) { //TODO why this can happen?
|
if ($this->mapBegan) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->mapBegan = true;
|
||||||
|
$this->mapEnded = false;
|
||||||
|
|
||||||
|
if (!isset($callback[1][0]["UId"])) {
|
||||||
|
// TODO: why can this even happen?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (array_key_exists($callback[1][0]["UId"], $this->maps)) {
|
if (array_key_exists($callback[1][0]["UId"], $this->maps)) {
|
||||||
// Map already exists, only update index
|
// Map already exists, only update index
|
||||||
$this->currentMap = $this->maps[$callback[1][0]["UId"]];
|
$this->currentMap = $this->maps[$callback[1][0]["UId"]];
|
||||||
} else {
|
} else {
|
||||||
// can this ever happen?
|
// TODO: can this ever happen?
|
||||||
$this->fetchCurrentMap();
|
$this->fetchCurrentMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Restructure MapList if id is over 15
|
// Restructure MapList if id is over 15
|
||||||
$this->restructureMapList();
|
$this->restructureMapList();
|
||||||
|
|
||||||
//Update the mx of the map (for update checks, etc.)
|
// Update the mx of the map (for update checks, etc.)
|
||||||
$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap);
|
$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap);
|
||||||
|
|
||||||
// Trigger own BeginMap callback
|
// Trigger own BeginMap callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap);
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Script BeginMap callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleScriptBeginMap(array $callback) {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle EndMap Callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleEndMap(array $callback) {
|
||||||
|
if ($this->mapEnded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->mapEnded = true;
|
||||||
|
$this->mapBegan = false;
|
||||||
|
|
||||||
|
// Trigger own EndMap callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Script EndMap Callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleScriptEndMap(array $callback) {
|
||||||
|
if ($this->mapEnded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->mapEnded = true;
|
||||||
|
$this->mapBegan = false;
|
||||||
|
|
||||||
|
// Trigger own EndMap callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -461,6 +510,8 @@ class MapManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get all Maps
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getMaps() {
|
public function getMaps() {
|
||||||
|
@ -42,7 +42,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ENDMAP, $this, 'endMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_ENDMAP, $this, 'endMap');
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
|
||||||
@ -140,9 +140,9 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
/**
|
/**
|
||||||
* Called on endmap
|
* Called on endmap
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function endMap(array $callback) {
|
public function endMap(Map $map) {
|
||||||
$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) {
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
|||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Maps\MapManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for the TM Game Mode 'Endurance' by TGYoshi
|
* Plugin for the TM Game Mode 'Endurance' by TGYoshi
|
||||||
@ -46,7 +47,7 @@ class EndurancePlugin implements CallbackListener, Plugin {
|
|||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'callback_OnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'callback_OnInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_BEGINMAP, $this, 'callback_BeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'callback_BeginMap');
|
||||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::CB_CHECKPOINT, $this, 'callback_Checkpoint');
|
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::CB_CHECKPOINT, $this, 'callback_Checkpoint');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -115,10 +116,10 @@ class EndurancePlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle BeginMap callback
|
* Handle BeginMap callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function callback_BeginMap(array $callback) {
|
public function callback_BeginMap(Map $map) {
|
||||||
$this->currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
$this->currentMap = $map;
|
||||||
$this->playerLapTimes = array();
|
$this->playerLapTimes = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ use ManiaControl\ManiaControl;
|
|||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Maps\MapManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Karma Plugin
|
* ManiaControl Karma Plugin
|
||||||
@ -76,7 +77,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_BEGINMAP, $this, 'handleBeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleBeginMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
||||||
|
|
||||||
@ -202,9 +203,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle BeginMap ManiaControl callback
|
* Handle BeginMap ManiaControl callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function handleBeginMap(array $callback) {
|
public function handleBeginMap(Map $map) {
|
||||||
$this->updateManialink = true;
|
$this->updateManialink = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ use FML\Controls\Control;
|
|||||||
use FML\Controls\Frame;
|
use FML\Controls\Frame;
|
||||||
use FML\Controls\Label;
|
use FML\Controls\Label;
|
||||||
use FML\Controls\Quad;
|
use FML\Controls\Quad;
|
||||||
|
use ManiaControl\Maps\MapManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Local Records Plugin
|
* ManiaControl Local Records Plugin
|
||||||
@ -79,9 +80,7 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_BEGINMAP, $this, 'handleMapBegin');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleMapBegin');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_CLIENTUPDATED, $this,
|
|
||||||
'handleClientUpdated');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this,
|
||||||
'handlePlayerFinish');
|
'handlePlayerFinish');
|
||||||
|
|
||||||
@ -189,9 +188,9 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle BeginMap callback
|
* Handle BeginMap callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function handleMapBegin(array $callback) {
|
public function handleMapBegin(Map $map) {
|
||||||
$this->updateManialink = true;
|
$this->updateManialink = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,15 +269,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle ClientUpdated callback
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handleClientUpdated(array $callback) {
|
|
||||||
$this->updateManialink = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the local records manialink
|
* Build the local records manialink
|
||||||
*
|
*
|
||||||
|
@ -10,6 +10,8 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
use ManiaControl\Statistics\StatisticCollector;
|
use ManiaControl\Statistics\StatisticCollector;
|
||||||
use ManiaControl\Statistics\StatisticManager;
|
use ManiaControl\Statistics\StatisticManager;
|
||||||
use Maniaplanet\DedicatedServer\Structures\AbstractStructure;
|
use Maniaplanet\DedicatedServer\Structures\AbstractStructure;
|
||||||
|
use ManiaControl\Maps\MapManager;
|
||||||
|
use ManiaControl\Maps\Map;
|
||||||
|
|
||||||
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||||
/**
|
/**
|
||||||
@ -84,7 +86,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
//Register CallbackListeners
|
//Register CallbackListeners
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ENDMAP, $this, 'handleEndMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_ENDMAP, $this, 'handleEndMap');
|
||||||
|
|
||||||
//Register CommandListener
|
//Register CommandListener
|
||||||
$this->maniaControl->commandManager->registerCommandListener('rank', $this, 'command_showRank', false);
|
$this->maniaControl->commandManager->registerCommandListener('rank', $this, 'command_showRank', false);
|
||||||
@ -285,9 +287,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
/**
|
/**
|
||||||
* Shows Ranks on endMap
|
* Shows Ranks on endMap
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function handleEndMap(array $callback) {
|
public function handleEndMap(Map $map) {
|
||||||
$this->resetRanks();
|
$this->resetRanks();
|
||||||
|
|
||||||
foreach($this->maniaControl->playerManager->getPlayers() as $player) {
|
foreach($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||||
|
@ -16,6 +16,8 @@ use ManiaControl\Manialinks\IconManager;
|
|||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Maps\MapManager;
|
||||||
|
use ManiaControl\Maps\Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Widget Plugin
|
* ManiaControl Widget Plugin
|
||||||
@ -95,8 +97,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$this->maniaControl->manialinkManager->customUIManager->setChallengeInfoVisible(false);
|
$this->maniaControl->manialinkManager->customUIManager->setChallengeInfoVisible(false);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_BEGINMAP, $this, 'handleOnBeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleOnBeginMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ENDMAP, $this, 'handleOnEndMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_ENDMAP, $this, 'handleOnEndMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||||
|
|
||||||
@ -379,9 +381,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle on Begin Map
|
* Handle on Begin Map
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function handleOnBeginMap(array $callback) {
|
public function handleOnBeginMap(Map $map) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget();
|
$this->displayMapWidget();
|
||||||
@ -403,9 +405,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle on End Map
|
* Handle on End Map
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function handleOnEndMap(array $callback) {
|
public function handleOnEndMap(Map $map) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayNextMapWidget();
|
$this->displayNextMapWidget();
|
||||||
|
Loading…
Reference in New Issue
Block a user