changed direct public access of maniacontrol properties to using getter methods

This commit is contained in:
Steffen Schröder
2014-08-03 01:34:18 +02:00
parent e560919096
commit 4d3dc92ad5
64 changed files with 2337 additions and 2055 deletions

View File

@ -54,14 +54,14 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
// Register for ManiaLink Actions
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SHOW, $this, 'handleActionShow');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_NAVIGATE_UP, $this, 'handleNavigateUp');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_NAVIGATE_ROOT, $this, 'handleNavigateRoot');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_OPEN_FOLDER), $this, 'handleOpenFolder');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_INSPECT_FILE), $this, 'handleInspectFile');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_ADD_FILE), $this, 'handleAddFile');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_ERASE_FILE), $this, 'handleEraseFile');
// ManiaLink Actions
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SHOW, $this, 'handleActionShow');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_NAVIGATE_UP, $this, 'handleNavigateUp');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_NAVIGATE_ROOT, $this, 'handleNavigateRoot');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_OPEN_FOLDER), $this, 'handleOpenFolder');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_INSPECT_FILE), $this, 'handleInspectFile');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_ADD_FILE), $this, 'handleAddFile');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_ERASE_FILE), $this, 'handleEraseFile');
}
/**
@ -94,7 +94,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$oldFolderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$isInMapsFolder = false;
if (!$oldFolderPath) {
$oldFolderPath = $this->maniaControl->server->getDirectory()->getMapsFolder();
$oldFolderPath = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
$isInMapsFolder = true;
}
$folderPath = $oldFolderPath;
@ -105,12 +105,12 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$folderName = basename($newFolderPath);
switch ($folderName) {
case 'Maps':
$mapsDir = dirname($this->maniaControl->server->getDirectory()->getMapsFolder());
$mapsDir = dirname($this->maniaControl->getServer()->getDirectory()->getMapsFolder());
$folderDir = dirname($folderPath);
$isInMapsFolder = ($mapsDir === $folderDir);
break;
case 'UserData':
$dataDir = dirname($this->maniaControl->server->getDirectory()->getGameDataFolder());
$dataDir = dirname($this->maniaControl->getServer()->getDirectory()->getGameDataFolder());
$folderDir = dirname($folderPath);
if ($dataDir === $folderDir) {
// Prevent navigation out of maps directory
@ -126,11 +126,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$script = $maniaLink->getScript();
$paging = new Paging();
$script->addFeature($paging);
$frame = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultListFrame($script, $paging);
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$width = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsHeight();
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
$index = 0;
$posY = $height / 2 - 10;
$pageFrame = null;
@ -154,7 +154,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$directoryLabel = new Label_Text();
$frame->add($directoryLabel);
$dataFolder = $this->maniaControl->server->getDirectory()->getGameDataFolder();
$dataFolder = $this->maniaControl->getServer()->getDirectory()->getGameDataFolder();
$directoryText = substr($folderPath, strlen($dataFolder));
$directoryLabel->setPosition($width * -0.41, $height * 0.45)
->setSize($width * 0.85, 4)
@ -181,8 +181,8 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
->setText('No files found.')
->setTranslate(true);
} else {
$canAddMaps = $this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP);
$canEraseMaps = $this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP);
$canAddMaps = $this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP);
$canEraseMaps = $this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP);
foreach ($mapFiles as $filePath => $fileName) {
$shortFilePath = substr($filePath, strlen($folderPath));
@ -264,7 +264,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
->setTranslate(true);
}
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, self::WIDGET_NAME);
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::WIDGET_NAME);
}
/**
@ -369,40 +369,40 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$filePath = $folderPath . $fileName;
$mapsFolder = $this->maniaControl->server->getDirectory()->getMapsFolder();
$mapsFolder = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
$relativeFilePath = substr($filePath, strlen($mapsFolder));
// Check for valid map
try {
$this->maniaControl->client->checkMapForCurrentServerParams($relativeFilePath);
$this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeFilePath);
} catch (InvalidMapException $exception) {
$this->maniaControl->chat->sendException($exception, $player);
$this->maniaControl->getChat()->sendException($exception, $player);
return;
} catch (FileException $exception) {
$this->maniaControl->chat->sendException($exception, $player);
$this->maniaControl->getChat()->sendException($exception, $player);
return;
}
// Add map to map list
try {
$this->maniaControl->client->insertMap($relativeFilePath);
$this->maniaControl->getClient()->insertMap($relativeFilePath);
} catch (AlreadyInListException $exception) {
$this->maniaControl->chat->sendException($exception, $player);
$this->maniaControl->getChat()->sendException($exception, $player);
return;
}
$map = $this->maniaControl->mapManager->fetchMapByFileName($relativeFilePath);
$map = $this->maniaControl->getMapManager()->fetchMapByFileName($relativeFilePath);
if (!$map) {
$this->maniaControl->chat->sendError('Error occurred.', $player);
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
return;
}
// Message
$message = $player->getEscapedNickname() . ' added ' . $map->getEscapedName() . '!';
$this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
// Queue requested Map
$this->maniaControl->mapManager->getMapQueue()->addMapToMapQueue($player, $map);
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($player, $map);
}
/**
@ -417,10 +417,10 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$filePath = $folderPath . $fileName;
if (@unlink($filePath)) {
$this->maniaControl->chat->sendSuccess("Erased {$fileName}!");
$this->maniaControl->getChat()->sendSuccess("Erased {$fileName}!");
$this->showManiaLink($player);
} else {
$this->maniaControl->chat->sendError("Couldn't erase {$fileName}!");
$this->maniaControl->getChat()->sendError("Couldn't erase {$fileName}!");
}
}
}

View File

@ -32,15 +32,15 @@ class MapActions {
* Skip the current Map
*/
public function skipMap() {
//Force a EndMap on the MapQueue to set the next Map
$this->maniaControl->mapManager->getMapQueue()->endMap(null);
// Force an EndMap on the MapQueue to set the next Map
$this->maniaControl->getMapManager()->getMapQueue()->endMap(null);
//ignore EndMap on MapQueue
$this->maniaControl->mapManager->getMapQueue()->dontQueueNextMapChange();
// Ignore EndMap on MapQueue
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
//Switch The Map
// Switch The Map
try {
$this->maniaControl->client->nextMap();
$this->maniaControl->getClient()->nextMap();
} catch (ChangeInProgressException $e) {
}
}

View File

@ -48,28 +48,28 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$this->maniaControl = $maniaControl;
$this->initActionsMenuButtons();
// Register for admin chat commands
$this->maniaControl->commandManager->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
$this->maniaControl->commandManager->registerCommandListener(array('restartmap', 'resmap', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.');
$this->maniaControl->commandManager->registerCommandListener(array('replaymap', 'replay'), $this, 'command_ReplayMap', true, 'Replays the current map (after the end of the map).');
$this->maniaControl->commandManager->registerCommandListener(array('addmap', 'add'), $this, 'command_AddMap', true, 'Adds map from ManiaExchange.');
$this->maniaControl->commandManager->registerCommandListener(array('removemap', 'removethis'), $this, 'command_RemoveMap', true, 'Removes the current map.');
$this->maniaControl->commandManager->registerCommandListener(array('erasemap', 'erasethis'), $this, 'command_EraseMap', true, 'Erases the current map.');
$this->maniaControl->commandManager->registerCommandListener(array('shufflemaps', 'shuffle'), $this, 'command_ShuffleMaps', true, 'Shuffles the maplist.');
$this->maniaControl->commandManager->registerCommandListener(array('writemaplist', 'wml'), $this, 'command_WriteMapList', true, 'Writes the current maplist to a file.');
$this->maniaControl->commandManager->registerCommandListener(array('readmaplist', 'rml'), $this, 'command_ReadMapList', true, 'Loads a maplist into the server.');
// Admin commands
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('replaymap', 'replay'), $this, 'command_ReplayMap', true, 'Replays the current map (after the end of the map).');
$this->maniaControl->getCommandManager()->registerCommandListener(array('addmap', 'add'), $this, 'command_AddMap', true, 'Adds map from ManiaExchange.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('removemap', 'removethis'), $this, 'command_RemoveMap', true, 'Removes the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('erasemap', 'erasethis'), $this, 'command_EraseMap', true, 'Erases the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('shufflemaps', 'shuffle'), $this, 'command_ShuffleMaps', true, 'Shuffles the maplist.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('writemaplist', 'wml'), $this, 'command_WriteMapList', true, 'Writes the current maplist to a file.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('readmaplist', 'rml'), $this, 'command_ReadMapList', true, 'Loads a maplist into the server.');
// Register for player chat commands
$this->maniaControl->commandManager->registerCommandListener('nextmap', $this, 'command_showNextMap', false, 'Shows which map is next.');
$this->maniaControl->commandManager->registerCommandListener(array('maps', 'list'), $this, 'command_List', false, 'Shows the current maplist (or variations).');
$this->maniaControl->commandManager->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.');
// Player commands
$this->maniaControl->getCommandManager()->registerCommandListener('nextmap', $this, 'command_showNextMap', false, 'Shows which map is next.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('maps', 'list'), $this, 'command_List', false, 'Shows the current maplist (or variations).');
$this->maniaControl->getCommandManager()->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.');
// Menu Buttons
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_RESTART_MAP, $this, 'command_RestartMap');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
// Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_RESTART_MAP, $this, 'command_RestartMap');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap');
}
/**
@ -78,28 +78,28 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
private function initActionsMenuButtons() {
// Menu Open xList
$itemQuad = new Quad();
$itemQuad->setImage($this->maniaControl->manialinkManager->getIconManager()->getIcon(IconManager::MX_ICON));
$itemQuad->setImageFocus($this->maniaControl->manialinkManager->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$itemQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
$itemQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
$this->maniaControl->actionsMenu->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
// Menu Open List
$itemQuad = new Quad_Icons64x64_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ToolRoot);
$itemQuad->setAction(self::ACTION_OPEN_MAPLIST);
$this->maniaControl->actionsMenu->addPlayerMenuItem($itemQuad, 10, 'Open MapList');
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 10, 'Open MapList');
// Menu RestartMap
$itemQuad = new Quad_UIConstruction_Buttons();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Reload);
$itemQuad->setAction(self::ACTION_RESTART_MAP);
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 10, 'Restart Map');
$this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad, 10, 'Restart Map');
// Menu NextMap
$itemQuad = new Quad_Icons64x64_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastNext);
$itemQuad->setAction(self::ACTION_SKIP_MAP);
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 20, 'Skip Map');
$this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad, 20, 'Skip Map');
}
/**
@ -109,18 +109,18 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_ShowNextMap(array $chatCallback, Player $player) {
$nextQueued = $this->maniaControl->mapManager->getMapQueue()->getNextQueuedMap();
$nextQueued = $this->maniaControl->getMapManager()->getMapQueue()->getNextQueuedMap();
if ($nextQueued) {
/** @var Player $requester */
$requester = $nextQueued[0];
/** @var Map $map */
$map = $nextQueued[1];
$this->maniaControl->chat->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$> requested by $<{$requester->nickname}$>.", $player);
$this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$> requested by $<{$requester->nickname}$>.", $player);
} else {
$mapIndex = $this->maniaControl->client->getNextMapIndex();
$maps = $this->maniaControl->mapManager->getMaps();
$mapIndex = $this->maniaControl->getClient()->getNextMapIndex();
$maps = $this->maniaControl->getMapManager()->getMaps();
$map = $maps[$mapIndex];
$this->maniaControl->chat->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$>.", $player);
$this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$>.", $player);
}
}
@ -131,19 +131,19 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_RemoveMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
// Get map
$map = $this->maniaControl->mapManager->getCurrentMap();
$map = $this->maniaControl->getMapManager()->getCurrentMap();
if (!$map) {
$this->maniaControl->chat->sendError("Couldn't remove map.", $player);
$this->maniaControl->getChat()->sendError("Couldn't remove map.", $player);
return;
}
// Remove map
$this->maniaControl->mapManager->removeMap($player, $map->uid);
$this->maniaControl->getMapManager()->removeMap($player, $map->uid);
}
/**
@ -153,19 +153,19 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_EraseMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
// Get map
$map = $this->maniaControl->mapManager->getCurrentMap();
$map = $this->maniaControl->getMapManager()->getCurrentMap();
if (!$map) {
$this->maniaControl->chat->sendError("Couldn't erase map.", $player);
$this->maniaControl->getChat()->sendError("Couldn't erase map.", $player);
return;
}
// Erase map
$this->maniaControl->mapManager->removeMap($player, $map->uid, true);
$this->maniaControl->getMapManager()->removeMap($player, $map->uid, true);
}
/**
@ -175,13 +175,13 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_ShuffleMaps(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
// Shuffles the maps
$this->maniaControl->mapManager->shuffleMapList($player);
$this->maniaControl->getMapManager()->shuffleMapList($player);
}
/**
@ -191,18 +191,18 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_AddMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$params = explode(' ', $chatCallback[1][2], 2);
if (count($params) < 2) {
$this->maniaControl->chat->sendUsageInfo('Usage example: //addmap 1234', $player->login);
$this->maniaControl->getChat()->sendUsageInfo('Usage example: //addmap 1234', $player);
return;
}
// add Map from Mania Exchange
$this->maniaControl->mapManager->addMapFromMx($params[1], $player->login);
$this->maniaControl->getMapManager()->addMapFromMx($params[1], $player->login);
}
/**
@ -212,15 +212,15 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_NextMap(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$this->maniaControl->mapManager->getMapActions()->skipMap();
$this->maniaControl->getMapManager()->getMapActions()->skipMap();
$message = '$<' . $player->nickname . '$> skipped the current Map!';
$this->maniaControl->chat->sendSuccess($message);
$message = $player->getEscapedNickname() . ' skipped the current Map!';
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
}
@ -231,16 +231,16 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_RestartMap(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$message = '$<' . $player->nickname . '$> restarted the current Map!';
$this->maniaControl->chat->sendSuccess($message);
$message = $player->getEscapedNickname() . ' restarted the current Map!';
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
try {
$this->maniaControl->client->restartMap();
$this->maniaControl->getClient()->restartMap();
} catch (ChangeInProgressException $e) {
}
}
@ -253,15 +253,15 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_ReplayMap(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$message = '$<' . $player->nickname . '$> replays the current Map!';
$this->maniaControl->chat->sendSuccess($message);
$message = $player->getEscapedNickname() . ' replays the current Map!';
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
$this->maniaControl->mapManager->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->mapManager->getCurrentMap());
$this->maniaControl->getMapManager()->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->getMapManager()->getCurrentMap());
}
/**
@ -271,8 +271,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_WriteMapList(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -289,13 +289,13 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
try {
$this->maniaControl->client->saveMatchSettings($maplist);
$this->maniaControl->getClient()->saveMatchSettings($maplist);
$message = 'Maplist $<$fff' . $maplist . '$> written.';
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->log($message, true);
} catch (FaultException $e) {
$this->maniaControl->chat->sendError('Cannot write maplist $<$fff' . $maplist . '$>!', $player);
$this->maniaControl->getChat()->sendError('Cannot write maplist $<$fff' . $maplist . '$>!', $player);
}
}
@ -306,8 +306,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_ReadMapList(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -324,14 +324,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
try {
$this->maniaControl->client->loadMatchSettings($maplist);
$this->maniaControl->getClient()->loadMatchSettings($maplist);
$message = 'Maplist $<$fff' . $maplist . '$> loaded.';
$this->maniaControl->mapManager->restructureMapList();
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getMapManager()->restructureMapList();
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->log($message, true);
} catch (FaultException $e) {
$this->maniaControl->chat->sendError('Cannot load maplist $<$fff' . $maplist . '$>!', $player);
$this->maniaControl->getChat()->sendError('Cannot load maplist $<$fff' . $maplist . '$>!', $player);
}
}
@ -344,11 +344,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$actionId = $callback[1][2];
$login = $callback[1][1];
$player = $this->maniaControl->playerManager->getPlayer($login);
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if (strstr($actionId, self::ACTION_SHOW_AUTHOR)) {
$login = str_replace(self::ACTION_SHOW_AUTHOR, '', $actionId);
$this->maniaControl->mapManager->getMapList()->playerCloseWidget($player);
$this->maniaControl->getMapManager()->getMapList()->playerCloseWidget($player);
$this->showMapListAuthor($login, $player);
}
}
@ -360,7 +360,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
private function showMapListAuthor($author, Player $player) {
$maps = $this->maniaControl->mapManager->getMaps();
$maps = $this->maniaControl->getMapManager()->getMaps();
$mapList = array();
/** @var Map $map */
foreach ($maps as $map) {
@ -370,11 +370,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
}
if (empty($mapList)) {
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
$this->maniaControl->getChat()->sendError('There are no maps to show!', $player->login);
return;
}
$this->maniaControl->mapManager->getMapList()->showMapList($player, $mapList);
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $mapList);
}
/**
@ -385,7 +385,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
*/
public function command_List(array $chatCallback, Player $player) {
$chatCommands = explode(' ', $chatCallback[1][2]);
$this->maniaControl->mapManager->getMapList()->playerCloseWidget($player);
$this->maniaControl->getMapManager()->getMapList()->playerCloseWidget($player);
if (isset($chatCommands[1])) {
$listParam = strtolower($chatCommands[1]);
@ -406,15 +406,15 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
if (isset($chatCommands[2])) {
$this->showMaplistAuthor($chatCommands[2], $player);
} else {
$this->maniaControl->chat->sendError('Missing Author Login!', $player->login);
$this->maniaControl->getChat()->sendError('Missing Author Login!', $player);
}
break;
default:
$this->maniaControl->mapManager->getMapList()->showMapList($player);
$this->maniaControl->getMapManager()->getMapList()->showMapList($player);
break;
}
} else {
$this->maniaControl->mapManager->getMapList()->showMapList($player);
$this->maniaControl->getMapManager()->getMapList()->showMapList($player);
}
}
@ -426,13 +426,13 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
*/
private function showMapListKarma($best, Player $player) {
/** @var \MCTeam\KarmaPlugin $karmaPlugin */
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(MapList::DEFAULT_KARMA_PLUGIN);
$karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(MapList::DEFAULT_KARMA_PLUGIN);
if ($karmaPlugin) {
$maps = $this->maniaControl->mapManager->getMaps();
$maps = $this->maniaControl->getMapManager()->getMaps();
$mapList = array();
foreach ($maps as $map) {
if ($map instanceof Map) {
if ($this->maniaControl->settingManager->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) {
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) {
$karma = $karmaPlugin->getMapKarma($map);
$map->karma = round($karma * 100.);
} else {
@ -463,9 +463,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$mapList = array_reverse($mapList);
}
$this->maniaControl->mapManager->getMapList()->showMapList($player, $mapList);
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $mapList);
} else {
$this->maniaControl->chat->sendError('KarmaPlugin is not enabled!', $player->login);
$this->maniaControl->getChat()->sendError('KarmaPlugin is not enabled!', $player->login);
}
}
@ -476,7 +476,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
private function showMapListDate($newest, Player $player) {
$maps = $this->maniaControl->mapManager->getMaps();
$maps = $this->maniaControl->getMapManager()->getMaps();
usort($maps, function (Map $mapA, Map $mapB) {
return ($mapA->index - $mapB->index);
@ -485,7 +485,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$maps = array_reverse($maps);
}
$this->maniaControl->mapManager->getMapList()->showMapList($player, $maps);
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $maps);
}
/**
@ -495,6 +495,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_xList(array $chatCallback, Player $player) {
$this->maniaControl->mapManager->getMXList()->showList($chatCallback, $player);
$this->maniaControl->getMapManager()->getMXList()->showList($chatCallback, $player);
}
}

View File

@ -70,17 +70,17 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
// Register for Callbacks
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'updateWidget');
// Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->getCallbackManager()->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'updateWidget');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CHECK_UPDATE, $this, 'checkUpdates');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLEAR_MAPQUEUE, $this, 'clearMapQueue');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CHECK_UPDATE, $this, 'checkUpdates');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CLEAR_MAPQUEUE, $this, 'clearMapQueue');
}
/**
@ -91,7 +91,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
*/
public function clearMapQueue(array $chatCallback, Player $player) {
// Clears the Map Queue
$this->maniaControl->mapManager->getMapQueue()
$this->maniaControl->getMapManager()->getMapQueue()
->clearMapQueue($player);
}
@ -103,7 +103,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
*/
public function checkUpdates(array $chatCallback, Player $player) {
// Update Mx Infos
$this->maniaControl->mapManager->getMXManager()->fetchManiaExchangeMapInformation();
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation();
// Reshow the Maplist
$this->showMapList($player);
@ -117,16 +117,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* @param int $pageIndex
*/
public function showMapList(Player $player, $mapList = null, $pageIndex = -1) {
$width = $this->maniaControl->manialinkManager->getStyleManager()
$width = $this->maniaControl->getManialinkManager()->getStyleManager()
->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->getStyleManager()
$height = $this->maniaControl->getManialinkManager()->getStyleManager()
->getListWidgetsHeight();
if ($pageIndex < 0) {
$pageIndex = (int)$player->getCache($this, self::CACHE_CURRENT_PAGE);
}
$player->setCache($this, self::CACHE_CURRENT_PAGE, $pageIndex);
$queueBuffer = $this->maniaControl->mapManager->getMapQueue()
$queueBuffer = $this->maniaControl->getMapManager()->getMapQueue()
->getQueueBuffer();
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex);
@ -134,11 +134,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Get Maps
if (!is_array($mapList)) {
$mapList = $this->maniaControl->mapManager->getMaps();
$mapList = $this->maniaControl->getMapManager()->getMaps();
}
$mapList = array_slice($mapList, $mapsBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE);
$totalMapsCount = $this->maniaControl->mapManager->getMapsCount();
$totalMapsCount = $this->maniaControl->getMapManager()->getMapsCount();
$pagesCount = ceil($totalMapsCount / self::MAX_MAPS_PER_PAGE);
// Create ManiaLink
@ -151,12 +151,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
// Main frame
$frame = $this->maniaControl->manialinkManager->getStyleManager()
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()
->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
// Admin Buttons
if ($this->maniaControl->authenticationManager->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
// Clear Map-Queue
$label = new Label_Button();
$frame->add($label);
@ -174,7 +174,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$quad->setAction(self::ACTION_CLEAR_MAPQUEUE);
}
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) {
// Check Update
$label = new Label_Button();
$frame->add($label);
@ -194,16 +194,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad = new Quad();
$frame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->manialinkManager->getIconManager()
$mxQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->getIconManager()
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setPosition($width / 2 - 67, -$height / 2 + 9);
$mxQuad->setZ(0.01);
$mxQuad->setAction(self::ACTION_CHECK_UPDATE);
}
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// Directory browser
$browserButton = new Label_Button();
$frame->add($browserButton);
@ -225,17 +225,17 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$headFrame->setY($height / 2 - 5);
$posX = -$width / 2;
$array = array('Id' => $posX + 5, 'Mx Id' => $posX + 10, 'Map Name' => $posX + 20, 'Author' => $posX + 68, 'Karma' => $posX + 115, 'Actions' => $width / 2 - 16);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
// Predefine description Label
$descriptionLabel = $this->maniaControl->manialinkManager->getStyleManager()
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()
->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$queuedMaps = $this->maniaControl->mapManager->getMapQueue()
$queuedMaps = $this->maniaControl->getMapManager()->getMapQueue()
->getQueuedMapsRanking();
/** @var KarmaPlugin $karmaPlugin */
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
$karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_KARMA_PLUGIN);
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
$paging->setStartPageNumber($pageIndex + 1);
@ -245,14 +245,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$posY = $height / 2 - 10;
$pageFrame = null;
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
$mxIcon = $this->maniaControl->manialinkManager->getIconManager()
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$mxIcon = $this->maniaControl->getManialinkManager()->getIconManager()
->getIcon(IconManager::MX_ICON);
$mxIconHover = $this->maniaControl->manialinkManager->getIconManager()
$mxIconHover = $this->maniaControl->getManialinkManager()->getIconManager()
->getIcon(IconManager::MX_ICON_MOVER);
$mxIconGreen = $this->maniaControl->manialinkManager->getIconManager()
$mxIconGreen = $this->maniaControl->getManialinkManager()->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN);
$mxIconGreenHover = $this->maniaControl->manialinkManager->getIconManager()
$mxIconGreenHover = $this->maniaControl->getManialinkManager()->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN_MOVER);
foreach ($mapList as $map) {
@ -300,7 +300,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->setX($posX + 65);
$mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01);
$description = 'View $<' . $map->name . '$> on Mania-Exchange';
$description = 'View ' . $map->getEscapedName() . ' on Mania-Exchange';
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
if ($map->updateAvailable()) {
@ -312,11 +312,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->setX($posX + 62);
$mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01);
$description = 'Update for $<' . $map->name . '$> available on Mania-Exchange!';
$description = 'Update for ' . $map->getEscapedName() . ' available on Mania-Exchange!';
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
// Update Button
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
$mxQuad->setAction(self::ACTION_UPDATE_MAP . '.' . $map->uid);
}
}
@ -324,7 +324,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Display Maps
$array = array($mapListId => $posX + 5, $mxId => $posX + 10, Formatter::stripDirtyCodes($map->name) => $posX + 20, $map->authorNick => $posX + 68);
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
if (isset($labels[3])) {
/** @var Label $label */
$label = $labels[3];
@ -346,14 +346,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$label->setTextColor('fff');
// Checks if the Player who opened the Widget has queued the map
$queuer = $this->maniaControl->mapManager->getMapQueue()
$queuer = $this->maniaControl->getMapManager()->getMapQueue()
->getQueuer($map->uid);
if ($queuer->login == $player->login) {
$description = 'Remove $<' . $map->name . '$> from the Map Queue';
$description = 'Remove ' . $map->getEscapedName() . ' from the Map Queue';
$label->addTooltipLabelFeature($descriptionLabel, $description);
$label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid);
} else {
$description = '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid];
$description = $map->getEscapedName() . ' is on Map-Queue Position: ' . $queuedMaps[$map->uid];
$label->addTooltipLabelFeature($descriptionLabel, $description);
}
} else {
@ -366,21 +366,21 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$queueLabel->setText('+');
if (in_array($map->uid, $queueBuffer)) {
if ($this->maniaControl->authenticationManager->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
$queueLabel->setAction(self::ACTION_QUEUED_MAP . '.' . $map->uid);
}
$queueLabel->setTextColor('f00');
$description = '$<' . $map->name . '$> has recently been played!';
$description = $map->getEscapedName() . ' has recently been played!';
$queueLabel->addTooltipLabelFeature($descriptionLabel, $description);
} else {
$queueLabel->setTextColor('09f');
$queueLabel->setAction(self::ACTION_QUEUED_MAP . '.' . $map->uid);
$description = 'Add $<' . $map->name . '$> to the Map Queue';
$description = 'Add ' . $map->getEscapedName() . ' to the Map Queue';
$queueLabel->addTooltipLabelFeature($descriptionLabel, $description);
}
}
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
// remove map button
$removeButton = new Label_Button();
$mapFrame->add($removeButton);
@ -393,11 +393,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$confirmFrame = $this->buildConfirmFrame($maniaLink, $posY, $map->uid, true);
$removeButton->addToggleFeature($confirmFrame);
$description = 'Remove Map: $<' . $map->name . '$>';
$description = 'Remove Map: ' . $map->getEscapedName();
$removeButton->addTooltipLabelFeature($descriptionLabel, $description);
}
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// Switch to button
$switchLabel = new Label_Button();
$mapFrame->add($switchLabel);
@ -411,11 +411,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$confirmFrame = $this->buildConfirmFrame($maniaLink, $posY, $map->uid);
$switchLabel->addToggleFeature($confirmFrame);
$description = 'Switch Directly to Map: $<' . $map->name . '$>';
$description = 'Switch Directly to Map: ' . $map->getEscapedName();
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
}
if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// Switch Map Voting for Admins
$switchQuad = new Quad_UIConstruction_Buttons();
$mapFrame->add($switchQuad);
@ -447,7 +447,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$karma = $karmaPlugin->getMapKarma($map);
$votes = $karmaPlugin->getMapVotes($map);
if (is_numeric($karma)) {
if ($this->maniaControl->settingManager->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) {
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) {
$karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';
} else {
$min = 0;
@ -494,7 +494,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$index++;
}
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, self::WIDGET_NAME);
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::WIDGET_NAME);
}
/**
@ -504,7 +504,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* @return int
*/
private function getChunkIndexFromPageNumber($pageIndex) {
$mapsCount = $this->maniaControl->mapManager->getMapsCount();
$mapsCount = $this->maniaControl->getMapManager()->getMapsCount();
$pagesCount = ceil($mapsCount / self::MAX_MAPS_PER_PAGE);
if ($pageIndex > $pagesCount - 1) {
$pageIndex = $pagesCount - 1;
@ -535,11 +535,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// TODO: get rid of the confirm frame to decrease xml size & network usage
// SUGGESTION: just send them as own manialink again on clicking?
$width = $this->maniaControl->manialinkManager->getStyleManager()
$width = $this->maniaControl->getManialinkManager()->getStyleManager()
->getListWidgetsWidth();
$quadStyle = $this->maniaControl->manialinkManager->getStyleManager()
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()
->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()
->getDefaultMainWindowSubStyle();
$confirmFrame = new Frame();
@ -620,57 +620,57 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$action = $actionArray[0] . '.' . $actionArray[1];
$login = $callback[1][1];
$player = $this->maniaControl->playerManager->getPlayer($login);
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
$mapUid = $actionArray[2];
switch ($action) {
case self::ACTION_UPDATE_MAP:
$this->maniaControl->mapManager->updateMap($player, $mapUid);
$this->maniaControl->getMapManager()->updateMap($player, $mapUid);
$this->showMapList($player);
break;
case self::ACTION_REMOVE_MAP:
$this->maniaControl->mapManager->removeMap($player, $mapUid);
$this->maniaControl->getMapManager()->removeMap($player, $mapUid);
break;
case self::ACTION_SWITCH_MAP:
// Don't queue on Map-Change
$this->maniaControl->mapManager->getMapQueue()->dontQueueNextMapChange();
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
try {
$this->maniaControl->client->jumpToMapIdent($mapUid);
$this->maniaControl->getClient()->jumpToMapIdent($mapUid);
} catch (NextMapException $exception) {
$this->maniaControl->chat->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player);
$this->maniaControl->getChat()->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player);
break;
} catch (NotInListException $exception) {
// TODO: "Map not found." -> how is that possible?
$this->maniaControl->chat->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player);
$this->maniaControl->getChat()->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player);
break;
}
$map = $this->maniaControl->mapManager->getMapByUid($mapUid);
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
$message = $player->getEscapedNickname() . ' skipped to Map $z' . $map->getEscapedName() . '!';
$this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
$this->playerCloseWidget($player);
break;
case self::ACTION_START_SWITCH_VOTE:
/** @var CustomVotesPlugin $votesPlugin */
$votesPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
$map = $this->maniaControl->mapManager->getMapByUid($mapUid);
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
$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) {
$votesPlugin->undefineVote('switchmap');
//Don't queue on Map-Change
$this->maniaControl->mapManager->getMapQueue()->dontQueueNextMapChange();
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
try {
$this->maniaControl->client->JumpToMapIdent($map->uid);
$this->maniaControl->getClient()->JumpToMapIdent($map->uid);
} catch (NextMapException $exception) {
return;
} catch (NotInListException $exception) {
@ -680,16 +680,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
return;
}
$this->maniaControl->chat->sendInformation('$sVote Successful -> Map switched!');
$this->maniaControl->getChat()->sendInformation('$sVote Successful -> Map switched!');
});
break;
case self::ACTION_QUEUED_MAP:
$this->maniaControl->mapManager->getMapQueue()
$this->maniaControl->getMapManager()->getMapQueue()
->addMapToMapQueue($callback[1][1], $mapUid);
$this->showMapList($player);
break;
case self::ACTION_UNQUEUE_MAP:
$this->maniaControl->mapManager->getMapQueue()
$this->maniaControl->getMapManager()->getMapQueue()
->removeFromMapQueue($player, $mapUid);
$this->showMapList($player);
break;
@ -710,14 +710,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
*/
public function playerCloseWidget(Player $player) {
$player->destroyCache($this, self::CACHE_CURRENT_PAGE);
$this->maniaControl->manialinkManager->closeWidget($player);
$this->maniaControl->getManialinkManager()->closeWidget($player);
}
/**
* Reopen the widget on Map Begin, MapListChanged, etc.
*/
public function updateWidget() {
$players = $this->maniaControl->playerManager->getPlayers();
$players = $this->maniaControl->getPlayerManager()->getPlayers();
foreach ($players as $player) {
$currentPage = $player->getCache($this, self::CACHE_CURRENT_PAGE);
if ($currentPage !== null) {

View File

@ -103,23 +103,23 @@ class MapManager implements CallbackListener {
$this->mapActions = new MapActions($maniaControl);
// Callbacks
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
// Permissions
$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_ERASE_MAP, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUFFLE_MAPS, AuthenticationManager::AUTH_LEVEL_ADMIN);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHECK_UPDATE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SKIP_MAP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_RESTART_MAP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_REMOVE_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ERASE_MAP, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_SHUFFLE_MAPS, AuthenticationManager::AUTH_LEVEL_ADMIN);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHECK_UPDATE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_SKIP_MAP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_RESTART_MAP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
// Settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_AUTOSAVE_MAPLIST, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAPLIST_FILE, "MatchSettings/tracklist.txt");
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WRITE_OWN_MAPLIST_FILE, false);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTOSAVE_MAPLIST, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIST_FILE, "MatchSettings/tracklist.txt");
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WRITE_OWN_MAPLIST_FILE, false);
}
/**
@ -128,7 +128,7 @@ class MapManager implements CallbackListener {
* @return bool
*/
private function initTables() {
$mysqli = $this->maniaControl->database->mysqli;
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_MAPS . "` (
`index` int(11) NOT NULL AUTO_INCREMENT,
`mxid` int(11),
@ -224,7 +224,7 @@ class MapManager implements CallbackListener {
if (!isset($uid) || !isset($this->maps[$uid])) {
trigger_error("Error while updating Map, unknown UID: " . $uid);
$this->maniaControl->chat->sendError("Error while updating Map.", $admin->login);
$this->maniaControl->getChat()->sendError("Error while updating Map.", $admin);
return;
}
@ -243,7 +243,7 @@ class MapManager implements CallbackListener {
* @return bool
*/
private function updateMapTimestamp($uid) {
$mysqli = $this->maniaControl->database->mysqli;
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
mxid = 0,
changed = NOW()
@ -274,7 +274,7 @@ class MapManager implements CallbackListener {
*/
public function removeMap(Player $admin, $uid, $eraseFile = false, $message = true) {
if (!isset($this->maps[$uid])) {
$this->maniaControl->chat->sendError("Map does not exist!", $admin);
$this->maniaControl->getChat()->sendError('Map does not exist!', $admin);
return;
}
@ -290,7 +290,7 @@ class MapManager implements CallbackListener {
// Remove map
try {
$this->maniaControl->client->removeMap($map->fileName);
$this->maniaControl->getClient()->removeMap($map->fileName);
} catch (NotInListException $e) {
}
@ -298,15 +298,15 @@ class MapManager implements CallbackListener {
if ($eraseFile) {
// Check if ManiaControl can even write to the maps dir
$mapDir = $this->maniaControl->client->getMapsDirectory();
if ($this->maniaControl->server->checkAccess($mapDir)) {
$mapDir = $this->maniaControl->getClient()->getMapsDirectory();
if ($this->maniaControl->getServer()->checkAccess($mapDir)) {
// Delete map file
if (!@unlink($mapDir . $map->fileName)) {
$this->maniaControl->chat->sendError("Couldn't erase the map file.", $admin);
$this->maniaControl->getChat()->sendError("Couldn't erase the map file.", $admin);
$eraseFile = false;
}
} else {
$this->maniaControl->chat->sendError("Couldn't erase the map file (no access).", $admin);
$this->maniaControl->getChat()->sendError("Couldn't erase the map file (no access).", $admin);
$eraseFile = false;
}
}
@ -315,7 +315,7 @@ class MapManager implements CallbackListener {
if ($message) {
$action = ($eraseFile ? 'erased' : 'removed');
$message = $admin->getEscapedNickname() . ' ' . $action . ' ' . $map->getEscapedName() . '!';
$this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
}
}
@ -330,22 +330,22 @@ class MapManager implements CallbackListener {
public function addMapFromMx($mapId, $login, $update = false) {
if (is_numeric($mapId)) {
// Check if map exists
$this->maniaControl->mapManager->getMXManager()->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (
$this->maniaControl->getMapManager()->getMXManager()->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (
&$login, &$update
) {
if (!$mapInfo || !isset($mapInfo->uploaded)) {
// Invalid id
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
$this->maniaControl->getChat()->sendError('Invalid MX-Id!', $login);
return;
}
// Download the file
$this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (
$this->maniaControl->getFileReader()->loadFile($mapInfo->downloadurl, function ($file, $error) use (
&$login, &$mapInfo, &$update
) {
if (!$file || $error) {
// Download error
$this->maniaControl->chat->sendError("Download failed: '{$error}'!", $login);
$this->maniaControl->getChat()->sendError("Download failed: '{$error}'!", $login);
return;
}
$this->processMapFile($file, $mapInfo, $login, $update);
@ -366,7 +366,7 @@ class MapManager implements CallbackListener {
private function processMapFile($file, MXMapInfo $mapInfo, $login, $update) {
// Check if map is already on the server
if ($this->getMapByUid($mapInfo->uid)) {
$this->maniaControl->chat->sendError('Map is already on the server!', $login);
$this->maniaControl->getChat()->sendError('Map is already on the server!', $login);
return;
}
@ -374,34 +374,34 @@ class MapManager implements CallbackListener {
$fileName = $mapInfo->id . '_' . $mapInfo->name . '.Map.Gbx';
$fileName = FileUtil::getClearedFileName($fileName);
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
$downloadFolderName = $this->maniaControl->getSettingManager()->getSettingValue($this, 'MapDownloadDirectory', 'MX');
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
$mapDir = $this->maniaControl->server->getDirectory()
$mapDir = $this->maniaControl->getServer()->getDirectory()
->getMapsFolder();
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
$fullMapFileName = $downloadDirectory . $fileName;
// Check if it can get written locally
if ($this->maniaControl->server->checkAccess($mapDir)) {
if ($this->maniaControl->getServer()->checkAccess($mapDir)) {
// Create download directory if necessary
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) {
trigger_error("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.");
$this->maniaControl->chat->sendError("ManiaControl doesn't have the rights to save maps.", $login);
$this->maniaControl->getChat()->sendError("ManiaControl doesn't have the rights to save maps.", $login);
return;
}
if (!file_put_contents($fullMapFileName, $file)) {
// Save error
$this->maniaControl->chat->sendError('Saving map failed!', $login);
$this->maniaControl->getChat()->sendError('Saving map failed!', $login);
return;
}
} else {
// Write map via write file method
try {
$this->maniaControl->client->writeFile($relativeMapFileName, $file);
$this->maniaControl->getClient()->writeFile($relativeMapFileName, $file);
} catch (InvalidArgumentException $e) {
if ($e->getMessage() === 'data are too big') {
$this->maniaControl->chat->sendError("Map is too big for a remote save.", $login);
$this->maniaControl->getChat()->sendError("Map is too big for a remote save.", $login);
return;
}
throw $e;
@ -410,49 +410,49 @@ class MapManager implements CallbackListener {
// Check for valid map
try {
$this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName);
$this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeMapFileName);
} catch (InvalidMapException $exception) {
$this->maniaControl->chat->sendException($exception, $login);
$this->maniaControl->getChat()->sendException($exception, $login);
return;
} catch (FileException $exception) {
$this->maniaControl->chat->sendException($exception, $login);
$this->maniaControl->getChat()->sendException($exception, $login);
return;
}
// Add map to map list
try {
$this->maniaControl->client->insertMap($relativeMapFileName);
$this->maniaControl->getClient()->insertMap($relativeMapFileName);
} catch (AlreadyInListException $exception) {
$this->maniaControl->chat->sendException($exception, $login);
$this->maniaControl->getChat()->sendException($exception, $login);
return;
}
$this->updateFullMapList();
// Update Mx MapInfo
$this->maniaControl->mapManager->getMXManager()->updateMapObjectsWithManiaExchangeIds(array($mapInfo));
$this->maniaControl->getMapManager()->getMXManager()->updateMapObjectsWithManiaExchangeIds(array($mapInfo));
// Update last updated time
$map = $this->getMapByUid($mapInfo->uid);
if (!$map) {
// TODO: improve this - error reports about not existing maps
$this->maniaControl->errorHandler->triggerDebugNotice('Map not in List after Insert!');
$this->maniaControl->chat->sendError('Server Error!', $login);
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Map not in List after Insert!');
$this->maniaControl->getChat()->sendError('Server Error!', $login);
return;
}
$map->lastUpdate = time();
$player = $this->maniaControl->playerManager->getPlayer($login);
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if (!$update) {
// Message
$message = '$<' . $player->nickname . '$> added $<' . $mapInfo->name . '$>!';
$this->maniaControl->chat->sendSuccess($message);
$message = $player->getEscapedNickname() . ' added $<' . $mapInfo->name . '$>!';
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
// Queue requested Map
$this->maniaControl->mapManager->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid);
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid);
} else {
$message = '$<' . $player->nickname . '$> updated $<' . $mapInfo->name . '$>!';
$this->maniaControl->chat->sendSuccess($message);
$message = $player->getEscapedNickname() . ' updated $<' . $mapInfo->name . '$>!';
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
}
}
@ -478,8 +478,8 @@ class MapManager implements CallbackListener {
try {
$offset = 0;
while ($this->maniaControl->client) {
$maps = $this->maniaControl->client->getMapList(150, $offset);
while ($this->maniaControl->getClient()) {
$maps = $this->maniaControl->getClient()->getMapList(150, $offset);
foreach ($maps as $rpcMap) {
if (array_key_exists($rpcMap->uId, $this->maps)) {
@ -501,18 +501,19 @@ class MapManager implements CallbackListener {
$this->maps = $tempList;
// Trigger own callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPS_UPDATED);
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPS_UPDATED);
// Write MapList
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_AUTOSAVE_MAPLIST)) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WRITE_OWN_MAPLIST_FILE)) {
$matchSettingsFileName = "MatchSettings/{$this->maniaControl->server->login}.txt";
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_AUTOSAVE_MAPLIST)) {
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WRITE_OWN_MAPLIST_FILE)) {
$serverLogin = $this->maniaControl->getServer()->login;
$matchSettingsFileName = "MatchSettings/{$serverLogin}.txt";
} else {
$matchSettingsFileName = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIST_FILE);
$matchSettingsFileName = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIST_FILE);
}
try {
$this->maniaControl->client->saveMatchSettings($matchSettingsFileName);
$this->maniaControl->getClient()->saveMatchSettings($matchSettingsFileName);
} catch (FileException $e) {
$this->maniaControl->log("Unable to write the playlist file, please checkout your MX-Folders File permissions!");
}
@ -539,7 +540,7 @@ class MapManager implements CallbackListener {
*/
private function saveMap(Map &$map) {
//TODO saveMaps for whole maplist at once (usage of prepared statements)
$mysqli = $this->maniaControl->database->mysqli;
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
$mapQuery = "INSERT INTO `" . self::TABLE_MAPS . "` (
`uid`,
`name`,
@ -592,10 +593,10 @@ class MapManager implements CallbackListener {
}
try {
$this->maniaControl->client->chooseNextMapList($mapArray);
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
} catch (Exception $e) {
//TODO temp added 19.04.2014
$this->maniaControl->errorHandler->triggerDebugNotice("Exception line 331 MapManager" . $e->getMessage());
$this->maniaControl->getErrorHandler()->triggerDebugNotice("Exception line 331 MapManager" . $e->getMessage());
trigger_error("Couldn't shuffle mapList. " . $e->getMessage());
return false;
}
@ -603,8 +604,8 @@ class MapManager implements CallbackListener {
$this->fetchCurrentMap();
if ($admin) {
$message = '$<' . $admin->nickname . '$> shuffled the Maplist!';
$this->maniaControl->chat->sendSuccess($message);
$message = $admin->getEscapedNickname() . ' shuffled the Maplist!';
$this->maniaControl->getChat()->sendSuccess($message);
$this->maniaControl->log($message, true);
}
@ -620,7 +621,7 @@ class MapManager implements CallbackListener {
*/
private function fetchCurrentMap() {
try {
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
$rpcMap = $this->maniaControl->getClient()->getCurrentMapInfo();
} catch (UnavailableFeatureException $exception) {
return null;
}
@ -665,7 +666,7 @@ class MapManager implements CallbackListener {
array_shift($mapArray);
try {
$this->maniaControl->client->chooseNextMapList($mapArray);
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
} catch (Exception $e) {
trigger_error("Error while restructuring the Maplist. " . $e->getMessage());
return false;
@ -764,7 +765,7 @@ class MapManager implements CallbackListener {
// Map already exists, only update index
$this->currentMap = $this->maps[$uid];
if (!$this->currentMap->nbCheckpoints || !$this->currentMap->nbLaps) {
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
$rpcMap = $this->maniaControl->getClient()->getCurrentMapInfo();
$this->currentMap->nbLaps = $rpcMap->nbLaps;
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
}
@ -777,7 +778,7 @@ class MapManager implements CallbackListener {
$this->getMXManager()->fetchManiaExchangeMapInformation($this->currentMap);
// Trigger own BeginMap callback
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
}
/**
@ -791,7 +792,7 @@ class MapManager implements CallbackListener {
$this->mapBegan = false;
// Trigger own EndMap callback
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
}
/**
@ -801,7 +802,7 @@ class MapManager implements CallbackListener {
* @return Map
*/
public function fetchMapByFileName($relativeFileName) {
$mapInfo = $this->maniaControl->client->getMapInfo($relativeFileName);
$mapInfo = $this->maniaControl->getClient()->getMapInfo($relativeFileName);
if (!$mapInfo) {
return null;
}

View File

@ -53,24 +53,26 @@ class MapQueue implements CallbackListener, CommandListener {
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ENDMAP, $this, 'endMap');
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'beginMap');
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
// Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'endMap');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'beginMap');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
// Init settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAPLIMIT_PLAYER, 1);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAPLIMIT_ADMIN, -1);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_BUFFERSIZE, 10);
// Settings
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_PLAYER, 1);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_ADMIN, -1);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
// Permissions
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
//Register Admin Commands
$this->maniaControl->commandManager->registerCommandListener(self::ADMIN_COMMAND_CLEAR_JUKEBOX, $this, 'command_ClearMapQueue', true, 'Clears the Map-Queue.');
$this->maniaControl->commandManager->registerCommandListener(self::ADMIN_COMMAND_CLEAR_MAPQUEUE, $this, 'command_ClearMapQueue', true, 'Clears the Map-Queue.');
$this->maniaControl->commandManager->registerCommandListener(array('jb', 'jukebox', 'mapqueue'), $this, 'command_MapQueue', false, 'Shows current maps in Map-Queue.');
// Admin Commands
$this->maniaControl->getCommandManager()->registerCommandListener(self::ADMIN_COMMAND_CLEAR_JUKEBOX, $this, 'command_ClearMapQueue', true, 'Clears the Map-Queue.');
$this->maniaControl->getCommandManager()->registerCommandListener(self::ADMIN_COMMAND_CLEAR_MAPQUEUE, $this, 'command_ClearMapQueue', true, 'Clears the Map-Queue.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('jb', 'jukebox', 'mapqueue'), $this, 'command_MapQueue', false, 'Shows current maps in Map-Queue.');
}
/**
@ -84,7 +86,7 @@ class MapQueue implements CallbackListener, CommandListener {
* Add current map to buffer on startup
*/
public function handleAfterInit() {
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$this->buffer[] = $currentMap->uid;
}
@ -104,26 +106,26 @@ class MapQueue implements CallbackListener, CommandListener {
* @param Player $admin
*/
public function clearMapQueue(Player $admin) {
if (!$this->maniaControl->authenticationManager->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
$this->maniaControl->authenticationManager->sendNotAllowed($admin);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
return;
}
if (empty($this->queuedMaps)) {
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $admin->login);
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $admin->login);
return;
}
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
//Destroy map - queue list
$this->queuedMaps = array();
$this->maniaControl->chat->sendInformation('$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Queued-Map list!');
$this->maniaControl->getChat()->sendInformation('$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Queued-Map list!');
$this->maniaControl->log($title . ' ' . Formatter::stripCodes($admin->nickname) . ' cleared the Queued-Map list!');
// Trigger callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear'));
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear'));
}
/**
@ -163,7 +165,7 @@ class MapQueue implements CallbackListener, CommandListener {
*/
public function showMapQueue(Player $player) {
if (empty($this->queuedMaps)) {
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login);
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $player->login);
return;
}
@ -174,7 +176,7 @@ class MapQueue implements CallbackListener, CommandListener {
$index++;
}
$this->maniaControl->chat->sendInformation($message, $player->login);
$this->maniaControl->getChat()->sendInformation($message, $player);
}
/**
@ -184,7 +186,7 @@ class MapQueue implements CallbackListener, CommandListener {
*/
public function showMapQueueManialink(Player $player) {
if (empty($this->queuedMaps)) {
$this->maniaControl->chat->sendError('There are no Maps in the Jukebox!', $player);
$this->maniaControl->getChat()->sendError('There are no Maps in the Jukebox!', $player);
return;
}
@ -193,7 +195,7 @@ class MapQueue implements CallbackListener, CommandListener {
array_push($maps, $queuedMap[1]);
}
$this->maniaControl->mapManager->getMapList()->showMapList($player, $maps);
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $maps);
}
/**
@ -228,13 +230,13 @@ class MapQueue implements CallbackListener, CommandListener {
* @param string $uid
*/
public function addMapToMapQueue($login, $uid) {
$player = $this->maniaControl->playerManager->getPlayer($login);
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if (!$player) {
return;
}
//Check if player is allowed to add (another) map
$isModerator = $this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$isModerator = $this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$mapsForPlayer = 0;
foreach ($this->queuedMaps as $queuedMap) {
@ -244,15 +246,15 @@ class MapQueue implements CallbackListener, CommandListener {
}
if ($isModerator) {
$maxAdmin = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
$maxAdmin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login);
$this->maniaControl->getChat()->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login);
return;
}
} else {
$maxPlayer = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
$maxPlayer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) {
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxPlayer . '$> map(s) in the Map-Queue!', $login);
$this->maniaControl->getChat()->sendError('You already have $<$fff' . $maxPlayer . '$> map(s) in the Map-Queue!', $login);
return;
}
}
@ -264,29 +266,29 @@ class MapQueue implements CallbackListener, CommandListener {
$uid = $map->uid;
}
if (array_key_exists($uid, $this->queuedMaps)) {
$this->maniaControl->chat->sendError('That map is already in the Map-Queue!', $login);
$this->maniaControl->getChat()->sendError('That map is already in the Map-Queue!', $login);
return;
}
//TODO recently maps not able to add to queue-amps setting, and management
// Check if map is in the buffer
if (in_array($uid, $this->buffer)) {
$this->maniaControl->chat->sendError('That map has recently been played!', $login);
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
$this->maniaControl->getChat()->sendError('That map has recently been played!', $login);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
return;
}
}
if (!$map) {
$map = $this->maniaControl->mapManager->getMapByUid($uid);
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
}
$this->queuedMaps[$uid] = array($player, $map);
$this->maniaControl->chat->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by $<$fff' . $player->nickname . '$>.');
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by $<$fff' . $player->nickname . '$>.');
// Trigger callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
}
/**
@ -303,10 +305,10 @@ class MapQueue implements CallbackListener, CommandListener {
$map = $this->queuedMaps[$uid][1];
unset($this->queuedMaps[$uid]);
$this->maniaControl->chat->sendInformation('$fa0$<$fff' . $map->name . '$> is removed from the Map-Queue by $<$fff' . $player->nickname . '$>.');
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> is removed from the Map-Queue by $<$fff' . $player->nickname . '$>.');
// Trigger callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('remove', $map));
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('remove', $map));
}
/**
@ -322,7 +324,7 @@ class MapQueue implements CallbackListener, CommandListener {
}
$this->nextMap = null;
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
// Skip Map if requester has left
foreach ($this->queuedMaps as $queuedMap) {
$player = $queuedMap[0];
@ -333,11 +335,11 @@ class MapQueue implements CallbackListener, CommandListener {
}
//found player, so play this map
if ($this->maniaControl->playerManager->getPlayer($player->login)) {
if ($this->maniaControl->getPlayerManager()->getPlayer($player->login)) {
break;
}
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN)) {
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN)) {
//Check if the queuer is a admin
if ($player->authLevel > 0) {
break;
@ -345,12 +347,12 @@ class MapQueue implements CallbackListener, CommandListener {
}
// Trigger callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('skip', $queuedMap[0]));
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('skip', $queuedMap[0]));
//Player not found, so remove the map from the mapqueue
array_shift($this->queuedMaps);
$this->maniaControl->chat->sendInformation('$fa0$<$fff' . $queuedMap[0]->name . '$> is skipped because $<' . $player->nickname . '$> left the game!');
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $queuedMap[0]->name . '$> is skipped because $<' . $player->nickname . '$> left the game!');
}
}
@ -362,10 +364,10 @@ class MapQueue implements CallbackListener, CommandListener {
}
$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->getChat()->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
try {
$this->maniaControl->client->setNextMapIdent($map->uid);
$this->maniaControl->getClient()->setNextMapIdent($map->uid);
} catch (NextMapException $e) {
}
}
@ -380,7 +382,7 @@ class MapQueue implements CallbackListener, CommandListener {
return;
}
if (count($this->buffer) >= $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_BUFFERSIZE)) {
if (count($this->buffer) >= $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_BUFFERSIZE)) {
array_shift($this->buffer);
}