Changed Internal Callbacks formats to use objects directly instead of an array
This commit is contained in:
parent
36fc15c7b1
commit
ff9c21a8af
@ -123,10 +123,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
|
||||
/**
|
||||
* Handle ManiaControl OnInit callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
public function handleOnInit() {
|
||||
$this->initCompleted = true;
|
||||
$this->rebuildAndShowMenu();
|
||||
}
|
||||
@ -149,10 +147,9 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Handle PlayerJoined callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerJoined(array $callback) {
|
||||
$player = $callback[1];
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
$manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML();
|
||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
|
||||
}
|
||||
|
@ -46,7 +46,10 @@ class AuthenticationManager implements CallbackListener {
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
||||
}
|
||||
|
||||
public function handleOnInit(array $callback) {
|
||||
/**
|
||||
* Handle ManiaControl OnInit Callback
|
||||
*/
|
||||
public function handleOnInit() {
|
||||
$this->updateMasterAdmins();
|
||||
}
|
||||
|
||||
@ -171,7 +174,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
$authStatement->close();
|
||||
|
||||
$player->authLevel = $authLevel;
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_AUTH_LEVEL_CHANGED, array(self::CB_AUTH_LEVEL_CHANGED, $player));
|
||||
$this->maniaControl->callbackManager->triggerCallback($player);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -155,14 +155,15 @@ class CallbackManager {
|
||||
* Trigger a specific Callback
|
||||
*
|
||||
* @param string $callbackName
|
||||
* @param array $callback
|
||||
*/
|
||||
public function triggerCallback($callbackName, array $callback) {
|
||||
public function triggerCallback($callbackName) {
|
||||
if (!array_key_exists($callbackName, $this->callbackListeners)) {
|
||||
return;
|
||||
}
|
||||
foreach($this->callbackListeners[$callbackName] as $listener) {
|
||||
call_user_func(array($listener[0], $listener[1]), $callback);
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 1, count($params), true);
|
||||
foreach ($this->callbackListeners[$callbackName] as $listener) {
|
||||
call_user_func_array(array($listener[0], $listener[1]), $params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,14 +171,15 @@ class CallbackManager {
|
||||
* Trigger a specific Script Callback
|
||||
*
|
||||
* @param string $callbackName
|
||||
* @param array $callback
|
||||
*/
|
||||
public function triggerScriptCallback($callbackName, array $callback) {
|
||||
public function triggerScriptCallback($callbackName) {
|
||||
if (!array_key_exists($callbackName, $this->scriptCallbackListener)) {
|
||||
return;
|
||||
}
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 1, count($params), true);
|
||||
foreach($this->scriptCallbackListener[$callbackName] as $listener) {
|
||||
call_user_func(array($listener[0], $listener[1]), $callback);
|
||||
call_user_func_array(array($listener[0], $listener[1]), $params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,10 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
||||
}
|
||||
|
||||
public function handleOnInit(array $callback) {
|
||||
/**
|
||||
* Handle ManiaControl OnInit Callback
|
||||
*/
|
||||
public function handleOnInit() {
|
||||
//Register the help command
|
||||
$this->maniaControl->commandManager->registerCommandListener('help', $this, 'command_playerHelp', false);
|
||||
$this->maniaControl->commandManager->registerCommandListener('help', $this, 'command_adminHelp', true);
|
||||
|
@ -15,6 +15,7 @@ use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Maps\MapManager;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
use ManiaControl\Maps\Map;
|
||||
|
||||
/**
|
||||
* Class offering a Configurator for Script Settings
|
||||
@ -85,20 +86,17 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle OnInit callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function onInit(array $callback) {
|
||||
public function onInit() {
|
||||
$this->loadSettingsFromDatabase();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle OnBegin Map Callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Map $map
|
||||
*/
|
||||
public function onBeginMap(array $callback) {
|
||||
public function onBeginMap(Map $map) {
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN)) {
|
||||
$this->loadSettingsFromDatabase();
|
||||
}
|
||||
@ -456,13 +454,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SCRIPTSETTING_CHANGED, array(self::CB_SCRIPTSETTING_CHANGED, $setting, $value));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SCRIPTSETTING_CHANGED, $setting, $value);
|
||||
|
||||
$settingIndex++;
|
||||
}
|
||||
$statement->close();
|
||||
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SCRIPTSETTINGS_CHANGED, array(self::CB_SCRIPTSETTINGS_CHANGED));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SCRIPTSETTINGS_CHANGED);
|
||||
|
||||
$chatMessage .= '!';
|
||||
$this->maniaControl->chat->sendInformation($chatMessage);
|
||||
|
@ -80,10 +80,8 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle OnInit callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function onInit(array $callback) {
|
||||
public function onInit() {
|
||||
$this->loadSettingsFromDatabase();
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ class ErrorHandler {
|
||||
* Private Properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
private $reportErrors = true;
|
||||
|
||||
/**
|
||||
* Construct Error Handler
|
||||
@ -42,6 +43,7 @@ class ErrorHandler {
|
||||
$message .= "Trace: {$ex->getTraceAsString()}" . PHP_EOL;
|
||||
logMessage($message);
|
||||
|
||||
if ($this->reportErrors) {
|
||||
$error = array();
|
||||
$error["Type"] = "Exception";
|
||||
$error["Message"] = $message;
|
||||
@ -50,14 +52,17 @@ class ErrorHandler {
|
||||
|
||||
if ($this->maniaControl->server) {
|
||||
$error['ServerLogin'] = $this->maniaControl->server->login;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error['ServerLogin'] = '';
|
||||
}
|
||||
|
||||
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) {
|
||||
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager,
|
||||
UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$error['ManiaControlVersion'] = $this->maniaControl->updateManager->getCurrentBuildDate();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error['UpdateChannel'] = '';
|
||||
$error['ManiaControlVersion'] = ManiaControl::VERSION;
|
||||
}
|
||||
@ -70,9 +75,11 @@ class ErrorHandler {
|
||||
|
||||
if (!json_decode($success)) {
|
||||
logMessage("Exception-Report failed!");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
logMessage("Exception successfully reported!");
|
||||
}
|
||||
}
|
||||
|
||||
$this->maniaControl->restart();
|
||||
exit();
|
||||
@ -98,7 +105,7 @@ class ErrorHandler {
|
||||
$message = "{$errorTag}: {$errorString} in File '{$errorFile}' on Line {$errorLine}!";
|
||||
logMessage($message);
|
||||
|
||||
if ($errorNumber != E_USER_ERROR && $errorNumber != E_USER_WARNING && $errorNumber != E_USER_NOTICE) {
|
||||
if ($this->reportErrors && $errorNumber != E_USER_ERROR && $errorNumber != E_USER_WARNING && $errorNumber != E_USER_NOTICE) {
|
||||
$error = array();
|
||||
$error["Type"] = "Error";
|
||||
$error["Message"] = $message;
|
||||
@ -107,14 +114,17 @@ class ErrorHandler {
|
||||
|
||||
if ($this->maniaControl->server) {
|
||||
$error['ServerLogin'] = $this->maniaControl->server->login;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error['ServerLogin'] = '';
|
||||
}
|
||||
|
||||
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) {
|
||||
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager,
|
||||
UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$error['ManiaControlVersion'] = $this->maniaControl->updateManager->getCurrentBuildDate();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error['UpdateChannel'] = '';
|
||||
$error['ManiaControlVersion'] = ManiaControl::VERSION;
|
||||
}
|
||||
@ -127,7 +137,8 @@ class ErrorHandler {
|
||||
|
||||
if (!json_decode($success)) {
|
||||
logMessage("Error-Report failed!");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
logMessage("Error successfully reported!");
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ class ManiaControl implements CommandListener {
|
||||
*/
|
||||
public function handleShutdown() {
|
||||
// OnShutdown callback
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_ONSHUTDOWN, array(CallbackManager::CB_ONSHUTDOWN));
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_ONSHUTDOWN);
|
||||
|
||||
// Announce quit
|
||||
$this->chat->sendInformation('ManiaControl shutting down.');
|
||||
@ -245,7 +245,7 @@ class ManiaControl implements CommandListener {
|
||||
*/
|
||||
public function restart($message = null) {
|
||||
// Shutdown callback
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_ONSHUTDOWN, array(CallbackManager::CB_ONSHUTDOWN));
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_ONSHUTDOWN);
|
||||
|
||||
// Announce restart
|
||||
$this->chat->sendInformation('Restarting ManiaControl...');
|
||||
@ -282,13 +282,13 @@ class ManiaControl implements CommandListener {
|
||||
$this->connect();
|
||||
|
||||
// OnInit callback
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_ONINIT, array(CallbackManager::CB_ONINIT));
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_ONINIT);
|
||||
|
||||
// Load plugins
|
||||
$this->pluginManager->loadPlugins();
|
||||
|
||||
// AfterInit callback
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_AFTERINIT, array(CallbackManager::CB_AFTERINIT));
|
||||
$this->callbackManager->triggerCallback(CallbackManager::CB_AFTERINIT);
|
||||
|
||||
// Announce ManiaControl
|
||||
$this->chat->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!');
|
||||
|
@ -79,10 +79,9 @@ class CustomUIManager implements CallbackListener, TimerListener {
|
||||
/**
|
||||
* Handle PlayerJoined Callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerJoined(array $callback) {
|
||||
$player = $callback[1];
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
$this->updateManialink($player);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ use FML\ManiaLink;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
/**
|
||||
* Class managing Icons
|
||||
@ -86,29 +87,26 @@ class IconManager implements CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle OnInit Callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
public function handleOnInit() {
|
||||
$this->preloadIcons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PlayerConnect Callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$login = $callback[1];
|
||||
$this->preloadIcons($login);
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
$this->preloadIcons($player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload Icons
|
||||
*
|
||||
* @param string $login
|
||||
* @param Player $player
|
||||
*/
|
||||
public function preloadIcons($login = false) {
|
||||
public function preloadIcons($player = null) {
|
||||
$maniaLink = new ManiaLink(self::PRELOAD_MLID);
|
||||
$frame = new Frame();
|
||||
$maniaLink->add($frame);
|
||||
@ -123,6 +121,6 @@ class IconManager implements CallbackListener {
|
||||
|
||||
// Send manialink
|
||||
$manialinkText = $maniaLink->render()->saveXML();
|
||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player);
|
||||
}
|
||||
}
|
@ -138,9 +138,12 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
if (is_string($logins)) {
|
||||
return $this->maniaControl->client->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
if ($logins instanceof Player) {
|
||||
return $this->maniaControl->client->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
if (is_array($logins)) {
|
||||
$success = true;
|
||||
foreach($logins as $login) {
|
||||
foreach ($logins as $login) {
|
||||
$subSuccess = $this->maniaControl->client->sendDisplayManialinkPage($login, $manialinkText, $timeout, $hideOnClick);
|
||||
if (!$subSuccess) {
|
||||
$success = false;
|
||||
@ -201,7 +204,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
if ($widgetName != '') { //TODO make check by manialinkId, getter is needed to avoid uses on non main widgets
|
||||
$this->disableAltMenu($player);
|
||||
// Trigger callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_OPENED, array(self::CB_MAIN_WINDOW_OPENED, $player, $widgetName));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_OPENED, $player, $widgetName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,7 +232,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
$this->enableAltMenu($player);
|
||||
|
||||
// Trigger callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, array(self::CB_MAIN_WINDOW_CLOSED, $player));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, $player);
|
||||
} else {
|
||||
$emptyManialink = new ManiaLink($widgetId);
|
||||
$manialinkText = $emptyManialink->render()->saveXML();
|
||||
|
@ -561,10 +561,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
/**
|
||||
* Reopen the widget on Map Begin, MapListChanged, etc.
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function updateWidget(array $callback) {
|
||||
public function updateWidget() {
|
||||
foreach($this->mapListShown as $login => $shown) {
|
||||
if ($shown) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
|
@ -364,7 +364,7 @@ class MapManager implements CallbackListener {
|
||||
$this->maps = $tempList;
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPS_UPDATED, array(self::CB_MAPS_UPDATED));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPS_UPDATED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -389,10 +389,8 @@ class MapManager implements CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle OnInit callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
public function handleOnInit() {
|
||||
$this->updateFullMapList();
|
||||
$this->fetchCurrentMap();
|
||||
|
||||
@ -401,7 +399,6 @@ class MapManager implements CallbackListener {
|
||||
|
||||
//Restructure Maplist
|
||||
$this->restructureMapList();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,7 +447,7 @@ class MapManager implements CallbackListener {
|
||||
$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap);
|
||||
|
||||
// Trigger own BeginMap callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, array(self::CB_BEGINMAP, $this->currentMap));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap);
|
||||
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
//CallbackManager
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_STATUS_CHANGED, $this, 'teamStatusChanged');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
|
||||
// Action Open Playerlist
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||
@ -77,12 +77,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
/**
|
||||
* Handle TeamStatusChanged
|
||||
* @param array $callback
|
||||
*
|
||||
* @param bool $teamMode
|
||||
*/
|
||||
public function teamStatusChanged(array $callback) {
|
||||
$status = $callback[1];
|
||||
public function teamStatusChanged($teamMode) {
|
||||
//Add Balance Team Icon if it's a teamMode
|
||||
if ($status) {
|
||||
if ($teamMode) {
|
||||
// Action Balance Teams
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||
$itemQuad = new Quad_Icons128x32_1();
|
||||
|
@ -761,9 +761,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
/**
|
||||
* Reopen the widget on PlayerInfoChanged / Player Connect and Disconnect
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function updateWidget(array $callback) {
|
||||
public function updateWidget(Player $player) {
|
||||
foreach($this->playersListShown as $login => $shown) {
|
||||
if ($shown) {
|
||||
// Check if Shown player still exists
|
||||
|
@ -104,10 +104,8 @@ class PlayerManager implements CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle OnInit callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function onInit(array $callback) {
|
||||
public function onInit() {
|
||||
// Add all players
|
||||
$players = $this->maniaControl->client->getPlayerList(300, 0, 2);
|
||||
foreach($players as $playerItem) {
|
||||
@ -139,7 +137,8 @@ class PlayerManager implements CallbackListener {
|
||||
}
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT, array(self::CB_ONINIT));
|
||||
// TODO: what for?
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +167,7 @@ class PlayerManager implements CallbackListener {
|
||||
return;
|
||||
}
|
||||
// Trigger own callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECT, array(self::CB_PLAYERDISCONNECT, $player));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECT, $player);
|
||||
|
||||
if ($player->isFakePlayer()) {
|
||||
return;
|
||||
@ -194,7 +193,6 @@ class PlayerManager implements CallbackListener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$player->ladderRank = $callback[1][0]["LadderRanking"];
|
||||
$player->teamId = $callback[1][0]["TeamId"];
|
||||
|
||||
@ -224,11 +222,11 @@ class PlayerManager implements CallbackListener {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->server->index);
|
||||
|
||||
// Trigger own PlayerJoined callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERCONNECT, array(self::CB_PLAYERCONNECT, $player));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERCONNECT, $player);
|
||||
}
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERINFOCHANGED, array(self::CB_PLAYERINFOCHANGED));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERINFOCHANGED, $player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ class Server implements CallbackListener {
|
||||
* Constants
|
||||
*/
|
||||
const TABLE_SERVERS = 'mc_servers';
|
||||
const CB_TEAM_STATUS_CHANGED = 'ServerCallback.TeamStatusChanged';
|
||||
const CB_TEAM_MODE_CHANGED = 'ServerCallback.TeamModeChanged';
|
||||
|
||||
/**
|
||||
* Public Properties
|
||||
@ -126,10 +126,8 @@ class Server implements CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle OnInit Callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function onInit(array $callback) {
|
||||
public function onInit() {
|
||||
$this->updateProperties();
|
||||
}
|
||||
|
||||
@ -144,7 +142,7 @@ class Server implements CallbackListener {
|
||||
|
||||
// Trigger callback
|
||||
if ($oldStatus != $this->teamMode) {
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_STATUS_CHANGED, array(self::CB_TEAM_STATUS_CHANGED, $teamMode));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_MODE_CHANGED, $teamMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Menu items on init
|
||||
*
|
||||
* @param array $callback
|
||||
* Handle ManiaControl OnInit Callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
public function handleOnInit() {
|
||||
//Define Permissions
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN_SERVER, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHOW_SYSTEMINFO, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
@ -146,7 +144,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> canceled the Vote!');
|
||||
|
||||
// Trigger callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_VOTE_CANCELED, array(self::CB_VOTE_CANCELED, $player));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_VOTE_CANCELED, $player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,10 +43,8 @@ class SettingManager implements CallbackListener {
|
||||
|
||||
/**
|
||||
* Handle After Init Callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleAfterInit(array $callback) {
|
||||
public function handleAfterInit() {
|
||||
$this->deleteUnusedSettings();
|
||||
}
|
||||
|
||||
@ -318,7 +316,7 @@ class SettingManager implements CallbackListener {
|
||||
$settingStatement->close();
|
||||
|
||||
//Trigger settings changed Callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SETTINGS_CHANGED, array(self::CB_SETTINGS_CHANGED, $className, $settingName, $value));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SETTINGS_CHANGED, $className, $settingName, $value);
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
/**
|
||||
* Add the menu entry
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
public function handleOnInit() {
|
||||
$this->maniaControl->commandManager->registerCommandListener('stats', $this, 'command_ShowStatsList');
|
||||
|
||||
// Action Open StatsList
|
||||
|
@ -11,6 +11,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
class StatisticCollector implements CallbackListener {
|
||||
/**
|
||||
@ -54,7 +55,6 @@ class StatisticCollector implements CallbackListener {
|
||||
private $maniaControl = null;
|
||||
private $onShootArray = array();
|
||||
|
||||
|
||||
/**
|
||||
* Construct player manager
|
||||
*
|
||||
@ -76,11 +76,9 @@ class StatisticCollector implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* onInit
|
||||
*
|
||||
* @param array $callback
|
||||
* Handle ManiaControl OnInit Callback
|
||||
*/
|
||||
public function onInit(array $callback) {
|
||||
public function onInit() {
|
||||
//Define Stats MetaData
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME, StatisticManager::STAT_TYPE_TIME);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_MAP_WINS);
|
||||
@ -203,17 +201,15 @@ class StatisticCollector implements CallbackListener {
|
||||
/**
|
||||
* Insert OnShoot Statistic when a player leaves
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function onPlayerDisconnect(array $callback) {
|
||||
$player = $callback[1];
|
||||
|
||||
//Check if Stat Collecting is enabled
|
||||
public function onPlayerDisconnect(Player $player) {
|
||||
// Check if Stat Collecting is enabled
|
||||
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Insert Data into Database, and destroy player
|
||||
// Insert Data into Database, and destroy player
|
||||
if (isset($this->onShootArray[$player->login])) {
|
||||
if ($this->onShootArray[$player->login] > 0) {
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->server->index, $this->onShootArray[$player->login]);
|
||||
|
@ -108,14 +108,13 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
/**
|
||||
* Handle ManiaControl PlayerJoined callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerJoined(array $callback) {
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
if (!$this->coreUpdateData) {
|
||||
return;
|
||||
}
|
||||
// Announce available update
|
||||
$player = $callback[1];
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_UPDATE)) {
|
||||
return;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(self::CB_CUSTOM_VOTE_FINISHED, $this, 'handleVoteFinished');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_STATUS_CHANGED, $this, 'constructMenu');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'constructMenu');
|
||||
|
||||
//Settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_POSX, 156.);
|
||||
@ -193,10 +193,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
/**
|
||||
* Handle PlayerConnect callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$player = $callback[1];
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
$this->showIcon($player->login);
|
||||
}
|
||||
|
||||
@ -482,7 +481,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
//Check if vote is over
|
||||
if ($timeUntilExpire <= 0 || (($playersVoteRatio >= $this->currentVote->neededPlayerRatio) && (($votePercentage >= $this->currentVote->neededRatio) || ($votePercentage <= 1 - $this->currentVote->neededRatio)))) {
|
||||
// Trigger callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_CUSTOM_VOTE_FINISHED, array(self::CB_CUSTOM_VOTE_FINISHED, $this->currentVote->voteCommand->index, $votePercentage));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_CUSTOM_VOTE_FINISHED, $this->currentVote->voteCommand->index, $votePercentage);
|
||||
|
||||
//reset vote
|
||||
$this->destroyVote();
|
||||
|
@ -176,10 +176,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
/**
|
||||
* Handle PlayerConnect callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$player = $callback[1];
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
// Display Map Widget
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
|
||||
$this->displayDonateWidget($player->login);
|
||||
|
@ -125,9 +125,9 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
|
||||
/**
|
||||
* Function called on player connect and disconnect, changing the pointlimit.
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function changePointlimit(array $callback) {
|
||||
public function changePointlimit(Player $player) {
|
||||
$numberOfPlayers = 0;
|
||||
$numberOfSpectators = 0;
|
||||
|
||||
|
@ -37,8 +37,8 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
const SETTING_NOTIFY_BEST_RECORDS = 'Notify Publicly only for the X Best Records';
|
||||
const SETTING_ADJUST_OUTER_BORDER = 'Adjust outer Border to Number of actual Records';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
/*
|
||||
* Private Properties
|
||||
*/
|
||||
/**
|
||||
*
|
||||
@ -160,10 +160,8 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
/**
|
||||
* Handle ManiaControl After Init
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleAfterInit(array $callback) {
|
||||
public function handleAfterInit() {
|
||||
$this->updateManialink = true;
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$time = $data->Run->Time;
|
||||
// Trigger trackmania player finish callback
|
||||
$finishCallback = array($player->pid, $player->login, $time);
|
||||
$finishCallback = array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,7 +170,6 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
||||
// Trigger Trackmania player checkpoint callback
|
||||
// TODO: Checkpoint index (5th element)
|
||||
$checkpointCallback = array($player->pid, $player->login, $time, 0, 0);
|
||||
$checkpointCallback = array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
|
||||
}
|
||||
}
|
||||
|
@ -158,12 +158,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
||||
/**
|
||||
* Function handling on the connection of a player.
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$login = $callback[1]->login;
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
if($player->isSpectator) {
|
||||
$this->spectators[$player->login] = $player->login;
|
||||
$this->maniaControl->client->forceSpectator($player->login, 1);
|
||||
@ -180,11 +177,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
||||
/**
|
||||
* Function handling on the disconnection of a player.
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerDisconnect(array $callback) {
|
||||
/** @var Player $player */
|
||||
$player = $callback[1];
|
||||
public function handlePlayerDisconnect(Player $player) {
|
||||
if(isset($this->spectators[$player->login])) {
|
||||
unset($this->spectators[$player->login]);
|
||||
}
|
||||
|
@ -272,18 +272,12 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
$mysqli->query($query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle PlayerConnect callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$player = $callback[1];
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
$this->showRank($player);
|
||||
$this->showNextRank($player);
|
||||
}
|
||||
@ -306,7 +300,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
// Trigger callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_RANK_BUILT, array(self::CB_RANK_BUILT));
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_RANK_BUILT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,11 +152,9 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
|
||||
/**
|
||||
* Handle Player connect
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$player = $callback[1];
|
||||
/** @var Player $player */
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
$this->displayIcon($player->login);
|
||||
//Initialize Player
|
||||
$this->playerSettings[$player->index] = array("Balance" => $this->getBalance($player->index), "Won" => 0, "Spent" => 0, "Plays" => 0, "ClicksLastSecond" => 0, "Visible" => 0);
|
||||
@ -165,12 +163,10 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
|
||||
/**
|
||||
* Handle Player disconnect
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerDisconnect(array $callback) {
|
||||
public function handlePlayerDisconnect(Player $player) {
|
||||
$this->updateDatabaseEveryMinute();
|
||||
$player = $callback[1];
|
||||
unset($this->playerSettings[$player->index]);
|
||||
}
|
||||
|
||||
|
@ -514,10 +514,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
/**
|
||||
* Handle PlayerConnect callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(array $callback) {
|
||||
$player = $callback[1];
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
// Display Map Widget
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||
$this->displayMapWidget($player->login);
|
||||
@ -533,9 +532,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
/**
|
||||
* Handle PlayerConnect callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerDisconnect(array $callback) {
|
||||
public function handlePlayerDisconnect(Player $player) {
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||
$this->displayServerInfoWidget();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user