performed code formatting
This commit is contained in:
@ -50,27 +50,44 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$this->initActionsMenuButtons();
|
||||
|
||||
// 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.');
|
||||
$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.');
|
||||
|
||||
// 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.');
|
||||
$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.');
|
||||
|
||||
// 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');
|
||||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,28 +96,36 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
private function initActionsMenuButtons() {
|
||||
// Menu Open xList
|
||||
$itemQuad = new Quad();
|
||||
$itemQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$itemQuad->setImageFocus($this->maniaControl->getManialinkManager()->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->getActionsMenu()->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->getActionsMenu()->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->getActionsMenu()->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->getActionsMenu()->addAdminMenuItem($itemQuad, 20, 'Skip Map');
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addAdminMenuItem($itemQuad, 20, 'Skip Map');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,18 +135,24 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ShowNextMap(array $chatCallback, Player $player) {
|
||||
$nextQueued = $this->maniaControl->getMapManager()->getMapQueue()->getNextQueuedMap();
|
||||
$nextQueued = $this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->getNextQueuedMap();
|
||||
if ($nextQueued) {
|
||||
/** @var Player $requester */
|
||||
$requester = $nextQueued[0];
|
||||
/** @var Map $map */
|
||||
$map = $nextQueued[1];
|
||||
$this->maniaControl->getChat()->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->getClient()->getNextMapIndex();
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
$mapIndex = $this->maniaControl->getClient()
|
||||
->getNextMapIndex();
|
||||
$maps = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
$map = $maps[$mapIndex];
|
||||
$this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$>.", $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$>.", $player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,19 +163,25 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_RemoveMap(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
// Get map
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
if (!$map) {
|
||||
$this->maniaControl->getChat()->sendError("Couldn't remove map.", $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Couldn't remove map.", $player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove map
|
||||
$this->maniaControl->getMapManager()->removeMap($player, $map->uid);
|
||||
$this->maniaControl->getMapManager()
|
||||
->removeMap($player, $map->uid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,19 +191,25 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_EraseMap(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
// Get map
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
if (!$map) {
|
||||
$this->maniaControl->getChat()->sendError("Couldn't erase map.", $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Couldn't erase map.", $player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Erase map
|
||||
$this->maniaControl->getMapManager()->removeMap($player, $map->uid, true);
|
||||
$this->maniaControl->getMapManager()
|
||||
->removeMap($player, $map->uid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,13 +219,17 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_ShuffleMaps(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Shuffles the maps
|
||||
$this->maniaControl->getMapManager()->shuffleMapList($player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->shuffleMapList($player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,18 +239,23 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_AddMap(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->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->getChat()->sendUsageInfo('Usage example: //addmap 1234', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo('Usage example: //addmap 1234', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
// add Map from Mania Exchange
|
||||
$this->maniaControl->getMapManager()->addMapFromMx($params[1], $player->login);
|
||||
$this->maniaControl->getMapManager()
|
||||
->addMapFromMx($params[1], $player->login);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,15 +265,21 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_NextMap(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getMapManager()->getMapActions()->skipMap();
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapActions()
|
||||
->skipMap();
|
||||
|
||||
$message = $player->getEscapedNickname() . ' skipped the current Map!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
}
|
||||
|
||||
@ -232,16 +290,21 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_RestartMap(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' restarted the current Map!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()->restartMap();
|
||||
$this->maniaControl->getClient()
|
||||
->restartMap();
|
||||
} catch (ChangeInProgressException $e) {
|
||||
}
|
||||
}
|
||||
@ -254,15 +317,22 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_ReplayMap(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' replays the current Map!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->getMapManager()->getCurrentMap());
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->addFirstMapToMapQueue($player, $this->maniaControl->getMapManager()
|
||||
->getCurrentMap());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -272,8 +342,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_WriteMapList(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -290,13 +363,16 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
|
||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
||||
try {
|
||||
$this->maniaControl->getClient()->saveMatchSettings($maplist);
|
||||
$this->maniaControl->getClient()
|
||||
->saveMatchSettings($maplist);
|
||||
|
||||
$message = 'Maplist $<$fff' . $maplist . '$> written.';
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message, $player);
|
||||
Logger::logInfo($message, true);
|
||||
} catch (FaultException $e) {
|
||||
$this->maniaControl->getChat()->sendError('Cannot write maplist $<$fff' . $maplist . '$>!', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Cannot write maplist $<$fff' . $maplist . '$>!', $player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,8 +383,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_ReadMapList(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -325,14 +404,18 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
|
||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
||||
try {
|
||||
$this->maniaControl->getClient()->loadMatchSettings($maplist);
|
||||
$this->maniaControl->getClient()
|
||||
->loadMatchSettings($maplist);
|
||||
|
||||
$message = 'Maplist $<$fff' . $maplist . '$> loaded.';
|
||||
$this->maniaControl->getMapManager()->restructureMapList();
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->restructureMapList();
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message, $player);
|
||||
Logger::logInfo($message, true);
|
||||
} catch (FaultException $e) {
|
||||
$this->maniaControl->getChat()->sendError('Cannot load maplist $<$fff' . $maplist . '$>!', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Cannot load maplist $<$fff' . $maplist . '$>!', $player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,11 +428,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$actionId = $callback[1][2];
|
||||
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->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->getMapManager()->getMapList()->playerCloseWidget($player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->playerCloseWidget($player);
|
||||
$this->showMapListAuthor($login, $player);
|
||||
}
|
||||
}
|
||||
@ -361,7 +447,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
private function showMapListAuthor($author, Player $player) {
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
$maps = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
$mapList = array();
|
||||
/** @var Map $map */
|
||||
foreach ($maps as $map) {
|
||||
@ -371,11 +458,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
}
|
||||
|
||||
if (empty($mapList)) {
|
||||
$this->maniaControl->getChat()->sendError('There are no maps to show!', $player->login);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('There are no maps to show!', $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $mapList);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player, $mapList);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,7 +476,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
*/
|
||||
public function command_List(array $chatCallback, Player $player) {
|
||||
$chatCommands = explode(' ', $chatCallback[1][2]);
|
||||
$this->maniaControl->getMapManager()->getMapList()->playerCloseWidget($player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->playerCloseWidget($player);
|
||||
|
||||
if (isset($chatCommands[1])) {
|
||||
$listParam = strtolower($chatCommands[1]);
|
||||
@ -407,15 +499,20 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
if (isset($chatCommands[2])) {
|
||||
$this->showMaplistAuthor($chatCommands[2], $player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('Missing Author Login!', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Missing Author Login!', $player);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -427,13 +524,17 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
*/
|
||||
private function showMapListKarma($best, Player $player) {
|
||||
/** @var \MCTeam\KarmaPlugin $karmaPlugin */
|
||||
$karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(MapList::DEFAULT_KARMA_PLUGIN);
|
||||
$karmaPlugin = $this->maniaControl->getPluginManager()
|
||||
->getPlugin(MapList::DEFAULT_KARMA_PLUGIN);
|
||||
if ($karmaPlugin) {
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
$maps = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
$mapList = array();
|
||||
foreach ($maps as $map) {
|
||||
if ($map instanceof Map) {
|
||||
if ($this->maniaControl->getSettingManager()->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 {
|
||||
@ -464,9 +565,12 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$mapList = array_reverse($mapList);
|
||||
}
|
||||
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $mapList);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player, $mapList);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('KarmaPlugin is not enabled!', $player->login);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('KarmaPlugin is not enabled!', $player->login);
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,7 +581,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
private function showMapListDate($newest, Player $player) {
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
$maps = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
|
||||
usort($maps, function (Map $mapA, Map $mapB) {
|
||||
return ($mapA->index - $mapB->index);
|
||||
@ -486,7 +591,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$maps = array_reverse($maps);
|
||||
}
|
||||
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $maps);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player, $maps);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -496,6 +603,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_xList(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->getMapManager()->getMXList()->showList($chatCallback, $player);
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMXList()
|
||||
->showList($chatCallback, $player);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user