refactor codestyle (chaining)
This commit is contained in:
@@ -51,20 +51,14 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_POSY, -17.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSY, -17.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,12 +100,10 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
if (!$this->initCompleted) {
|
||||
return;
|
||||
}
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
foreach ($players as $player) {
|
||||
$manialink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($manialink, $player->login);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $player->login);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,28 +114,17 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* @return ManiaLink
|
||||
*/
|
||||
private function buildMenuIconsManialink(Player $player) {
|
||||
$posX = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$itemSize = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$shootManiaOffset = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultIconOffsetSM();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultQuadSubstyle();
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$shootManiaOffset = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultIconOffsetSM();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
// If game is shootmania lower the icons position by 20
|
||||
if ($this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame() === 'sm'
|
||||
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm'
|
||||
) {
|
||||
$posY -= $shootManiaOffset;
|
||||
}
|
||||
@@ -153,8 +134,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/*
|
||||
* Admin Menu
|
||||
*/
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
) {
|
||||
// Admin Menu Icon Frame
|
||||
$iconFrame = new Frame();
|
||||
@@ -333,7 +313,6 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
$maniaLink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($maniaLink, $player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,23 +46,17 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$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(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$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(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
|
||||
// Menu Entry AdminList
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_LIST, $this, 'openAdminList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_LIST, $this, 'openAdminList');
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author);
|
||||
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_LIST);
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addMenuItem($itemQuad, false, 50, 'Open AdminList');
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, false, 50, 'Open AdminList');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,16 +77,11 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
public function showAdminLists(Player $player) {
|
||||
$this->adminListShown[$player->login] = true;
|
||||
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
// get Admins
|
||||
$admins = $this->maniaControl->getAuthenticationManager()
|
||||
->getAdmins();
|
||||
$admins = $this->maniaControl->getAuthenticationManager()->getAdmins();
|
||||
|
||||
//Create ManiaLink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@@ -101,9 +90,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@@ -111,9 +98,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$posY = $height / 2;
|
||||
|
||||
//Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@@ -121,8 +106,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 5);
|
||||
$array = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Actions' => $posX + 120);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
|
||||
$index = 1;
|
||||
$posY -= 10;
|
||||
@@ -150,8 +134,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
|
||||
$array = array($index => $posX + 5, $admin->nickname => $posX + 18, $admin->login => $posX + 70);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($playerFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
|
||||
|
||||
|
||||
// Level Quad
|
||||
@@ -167,16 +150,13 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$rightLabel->setX($posX + 13.9);
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setZ(10);
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelAbbreviation($admin));
|
||||
$description = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin) . " " . $admin->nickname;
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($admin));
|
||||
$description = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin) . " " . $admin->nickname;
|
||||
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
//Revoke Button
|
||||
if ($admin->authLevel > 0
|
||||
&& $this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, $admin->authLevel + 1)
|
||||
&& $this->maniaControl->getAuthenticationManager()->checkRight($player, $admin->authLevel + 1)
|
||||
) {
|
||||
//Settings
|
||||
$style = Label_Text::STYLE_TextCardSmall;
|
||||
@@ -209,8 +189,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'AdminList');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'AdminList');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,9 +210,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
switch ($action) {
|
||||
case self::ACTION_REVOKE_RIGHTS:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -246,8 +223,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
public function updateWidget(Player $player) {
|
||||
foreach ($this->adminListShown as $login => $shown) {
|
||||
if ($shown) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if ($player) {
|
||||
$this->showAdminLists($player);
|
||||
} else {
|
||||
|
||||
@@ -29,12 +29,9 @@ class AuthCommands implements CommandListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Commands
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin', true, 'Add Player to the AdminList as SuperAdmin.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('addadmin', $this, 'command_AddAdmin', true, 'Add Player to the AdminList as Admin.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('addmod', $this, 'command_AddModerator', true, 'Add Player to the AdminList as Moderator.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin', true, 'Add Player to the AdminList as SuperAdmin.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('addadmin', $this, 'command_AddAdmin', true, 'Add Player to the AdminList as Admin.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('addmod', $this, 'command_AddModerator', true, 'Add Player to the AdminList as Moderator.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,8 +42,7 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
public function command_AddSuperAdmin(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
@@ -55,23 +51,18 @@ class AuthCommands implements CommandListener {
|
||||
$this->sendAddSuperAdminUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($commandParts[1]);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as SuperAdmin!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,8 +73,7 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
private function sendAddSuperAdminUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addsuperadmin login'";
|
||||
return $this->maniaControl->getChat()
|
||||
->sendUsageInfo($message, $player);
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,8 +84,7 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
public function command_AddAdmin(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
@@ -104,23 +93,18 @@ class AuthCommands implements CommandListener {
|
||||
$this->sendAddAdminUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($commandParts[1]);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Admin!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,8 +115,7 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
private function sendAddAdminUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addadmin login'";
|
||||
return $this->maniaControl->getChat()
|
||||
->sendUsageInfo($message, $player);
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,8 +126,7 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
public function command_AddModerator(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
@@ -153,23 +135,18 @@ class AuthCommands implements CommandListener {
|
||||
$this->sendAddModeratorUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($commandParts[1]);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Moderator!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +157,6 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
private function sendAddModeratorUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addmod login'";
|
||||
return $this->maniaControl->getChat()
|
||||
->sendUsageInfo($message, $player);
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
$this->authCommands = new AuthCommands($maniaControl);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,16 +146,14 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function updateMasterAdmins() {
|
||||
$masterAdminsElements = $this->maniaControl->getConfig()
|
||||
->xpath('masteradmins');
|
||||
$masterAdminsElements = $this->maniaControl->getConfig()->xpath('masteradmins');
|
||||
if (!$masterAdminsElements) {
|
||||
Logger::logError('Missing MasterAdmins configuration!');
|
||||
return false;
|
||||
}
|
||||
$masterAdminsElement = $masterAdminsElements[0];
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
// Remove all MasterAdmins
|
||||
$adminQuery = "UPDATE `" . PlayerManager::TABLE_PLAYERS . "`
|
||||
@@ -212,8 +209,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getConnectedAdmins($authLevel = self::AUTH_LEVEL_MODERATOR) {
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
$admins = array();
|
||||
foreach ($players as $player) {
|
||||
if (self::checkRight($player, $authLevel)) {
|
||||
@@ -244,8 +240,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getAdmins($authLevel = self::AUTH_LEVEL_MODERATOR) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT `login` FROM `" . PlayerManager::TABLE_PLAYERS . "`
|
||||
WHERE `authLevel` > " . $authLevel . "
|
||||
ORDER BY `authLevel` DESC;";
|
||||
@@ -256,8 +251,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
}
|
||||
$admins = array();
|
||||
while ($row = $result->fetch_object()) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($row->login, false);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($row->login, false);
|
||||
if ($player) {
|
||||
array_push($admins, $player);
|
||||
}
|
||||
@@ -282,8 +276,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$authQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
||||
`login`,
|
||||
`authLevel`
|
||||
@@ -306,8 +299,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
$authStatement->close();
|
||||
|
||||
$player->authLevel = $authLevel;
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_AUTH_LEVEL_CHANGED, $player);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_AUTH_LEVEL_CHANGED, $player);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -322,8 +314,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
if (!$player) {
|
||||
return false;
|
||||
}
|
||||
return $this->maniaControl->getChat()
|
||||
->sendError('You do not have the required Rights to perform this Action!', $player);
|
||||
return $this->maniaControl->getChat()->sendError('You do not have the required Rights to perform this Action!', $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,8 +325,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
public function checkPermission(Player $player, $rightName) {
|
||||
$right = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, $rightName);
|
||||
$right = $this->maniaControl->getSettingManager()->getSettingValue($this, $rightName);
|
||||
return $this->checkRight($player, $this->getAuthLevel($right));
|
||||
}
|
||||
|
||||
@@ -346,8 +336,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @param int $authLevelNeeded
|
||||
*/
|
||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, $rightName, $this->getPermissionLevelNameArray($authLevelNeeded));
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, $this->getPermissionLevelNameArray($authLevelNeeded));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,8 +41,7 @@ class BillManager implements CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,8 +55,7 @@ class BillManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') {
|
||||
$bill = $this->maniaControl->getClient()
|
||||
->sendBill($player->login, $amount, $message, $receiver);
|
||||
$bill = $this->maniaControl->getClient()->sendBill($player->login, $amount, $message, $receiver);
|
||||
$this->openBills[$bill] = new BillData($function, $player, $amount);
|
||||
return true;
|
||||
}
|
||||
@@ -72,8 +70,7 @@ class BillManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
public function sendPlanets(callable $function, $receiverLogin, $amount, $message) {
|
||||
$bill = $this->maniaControl->getClient()
|
||||
->pay($receiverLogin, $amount, $message);
|
||||
$bill = $this->maniaControl->getClient()->pay($receiverLogin, $amount, $message);
|
||||
$this->openBills[$bill] = new BillData($function, $receiverLogin, $amount, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -210,8 +210,7 @@ class CallbackManager {
|
||||
*/
|
||||
public function manageCallbacks() {
|
||||
// Manage Timings
|
||||
$this->maniaControl->getTimerManager()
|
||||
->manageTimings();
|
||||
$this->maniaControl->getTimerManager()->manageTimings();
|
||||
|
||||
// Server Callbacks
|
||||
if (!$this->maniaControl->getClient()) {
|
||||
@@ -219,8 +218,7 @@ class CallbackManager {
|
||||
}
|
||||
|
||||
// Handle callbacks
|
||||
$callbacks = $this->maniaControl->getClient()
|
||||
->executeCallbacks();
|
||||
$callbacks = $this->maniaControl->getClient()->executeCallbacks();
|
||||
foreach ($callbacks as $callback) {
|
||||
$this->handleCallback($callback);
|
||||
}
|
||||
@@ -238,16 +236,14 @@ class CallbackManager {
|
||||
$this->triggerCallback($callbackName, $callback);
|
||||
break;
|
||||
case self::CB_MP_BEGINMAP:
|
||||
$this->maniaControl->getMapManager()
|
||||
->handleBeginMap($callback);
|
||||
$this->maniaControl->getMapManager()->handleBeginMap($callback);
|
||||
$this->triggerCallback($callbackName, $callback);
|
||||
break;
|
||||
case self::CB_MP_ENDMATCH:
|
||||
$this->triggerCallback($callbackName, $callback);
|
||||
break;
|
||||
case self::CB_MP_ENDMAP:
|
||||
$this->maniaControl->getMapManager()
|
||||
->handleEndMap($callback);
|
||||
$this->maniaControl->getMapManager()->handleEndMap($callback);
|
||||
$this->triggerCallback($callbackName, $callback);
|
||||
break;
|
||||
case self::CB_MP_MODESCRIPTCALLBACK:
|
||||
|
||||
@@ -39,101 +39,79 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
||||
public function handleScriptCallback($name, $data) {
|
||||
switch ($name) {
|
||||
case 'LibXmlRpc_BeginMatch':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_LoadingMap':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::LOADINGMAP, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::LOADINGMAP, $data[0]);
|
||||
break;
|
||||
case 'BeginMap':
|
||||
case 'LibXmlRpc_BeginMap':
|
||||
if (!isset($data[2])) {
|
||||
$data[2] = 'False';
|
||||
}
|
||||
$this->maniaControl->getMapManager()
|
||||
->handleScriptBeginMap($data[1], $data[2]);
|
||||
$this->maniaControl->getMapManager()->handleScriptBeginMap($data[1], $data[2]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginSubmatch':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINSUBMATCH, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINSUBMATCH, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginTurn':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINTURN, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINTURN, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginPlaying':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINPLAYING);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINPLAYING);
|
||||
break;
|
||||
case 'LibXmlRpc_EndPlaying':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDPLAYING);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDPLAYING);
|
||||
break;
|
||||
case 'LibXmlRpc_EndTurn':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDTURN, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDTURN, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndRound':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDROUND, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndSubmatch':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDSUBMATCH, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDSUBMATCH, $data[0]);
|
||||
break;
|
||||
case 'EndMap':
|
||||
case 'LibXmlRpc_EndMap':
|
||||
$this->maniaControl->getMapManager()
|
||||
->handleScriptEndMap();
|
||||
$this->maniaControl->getMapManager()->handleScriptEndMap();
|
||||
break;
|
||||
case 'LibXmlRpc_BeginPodium':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINPODIUM);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINPODIUM);
|
||||
break;
|
||||
case 'LibXmlRpc_EndPodium':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDPODIUM);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDPODIUM);
|
||||
break;
|
||||
case 'LibXmlRpc_UnloadingMap':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::UNLOADINGMAP, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::UNLOADINGMAP, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndMatch':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDMATCH, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDMATCH, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginWarmUp':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINWARMUP);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINWARMUP);
|
||||
break;
|
||||
case 'LibXmlRpc_EndWarmUp':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDWARMUP);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDWARMUP);
|
||||
break;
|
||||
case 'LibXmlRpc_PlayerRanking':
|
||||
//TODO really useful? what does it have what RankingsManager not have?
|
||||
$this->triggerPlayerRanking($data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_OnStartLine':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONSTARTLINE, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSTARTLINE, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_OnWayPoint':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONWAYPOINT, $data);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONWAYPOINT, $data);
|
||||
break;
|
||||
case 'LibXmlRpc_OnGiveUp':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONGIVEUP, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONGIVEUP, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_OnRespawn':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONRESPAWN, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONRESPAWN, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_OnStunt':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONSTUNT, $data);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSTUNT, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -144,9 +122,7 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
||||
* @param array $data
|
||||
*/
|
||||
private function triggerPlayerRanking(array $data) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($data[1]);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::PLAYERRANKING, $player, $data[0], $data[6], $data[5]);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[1]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::PLAYERRANKING, $player, $data[0], $data[6], $data[5]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,20 +49,16 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
public function handleScriptCallbacks($name, $data) {
|
||||
switch ($name) {
|
||||
case 'LibXmlRpc_Rankings':
|
||||
$this->maniaControl->getServer()
|
||||
->getRankingManager()
|
||||
->updateRankings($data[0]);
|
||||
$this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_Scores':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::SCORES, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SCORES, $data[0]);
|
||||
break;
|
||||
case 'LibAFK_IsAFK':
|
||||
$this->triggerAfkStatus($data[0]);
|
||||
break;
|
||||
case 'WarmUp_Status':
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::WARMUPSTATUS, $data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::WARMUPSTATUS, $data[0]);
|
||||
break;
|
||||
case self::CB_TIMEATTACK_ONCHECKPOINT:
|
||||
$this->handleTimeAttackOnCheckpoint($name, $data);
|
||||
@@ -79,10 +75,8 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
* @param string $login
|
||||
*/
|
||||
private function triggerAfkStatus($login) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::AFKSTATUS, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::AFKSTATUS, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,8 +87,7 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
*/
|
||||
public function handleTimeAttackOnCheckpoint($name, array $data) {
|
||||
$login = $data[0];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@@ -106,8 +99,7 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
$checkpointCallback->setPlayer($player);
|
||||
$checkpointCallback->time = (int)$data[1];
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback($checkpointCallback);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($checkpointCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,8 +110,7 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
*/
|
||||
public function handleTimeAttackOnFinish($name, array $data) {
|
||||
$login = $data[0];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@@ -131,7 +122,6 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
$finishCallback->setPlayer($player);
|
||||
$finishCallback->time = (int)$data[1];
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback($finishCallback);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($finishCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
*/
|
||||
public function handleOnWayPointCallback(array $callback) {
|
||||
$login = $callback[0];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@@ -62,8 +61,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
$wayPointCallback->isEndLap = Formatter::parseBoolean($callback[7]);
|
||||
|
||||
if ($wayPointCallback->checkpoint > 0) {
|
||||
$currentMap = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$wayPointCallback->lap += $wayPointCallback->checkpoint / $currentMap->nbCheckpoints;
|
||||
}
|
||||
|
||||
@@ -75,8 +73,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
$wayPointCallback->name = $wayPointCallback::CHECKPOINT;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback($wayPointCallback);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($wayPointCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +84,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
public function handlePlayerCheckpointCallback(array $callback) {
|
||||
$data = $callback[1];
|
||||
$login = $data[1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@@ -104,8 +100,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
$checkpointCallback->lapCheckpoint = $checkpointCallback->checkpoint;
|
||||
|
||||
if ($checkpointCallback->lap > 0) {
|
||||
$currentMap = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$checkpointCallback->lapCheckpoint -= $checkpointCallback->lap * $currentMap->nbCheckpoints;
|
||||
}
|
||||
|
||||
@@ -115,8 +110,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
$checkpointCallback->name = $checkpointCallback::CHECKPOINT;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback($checkpointCallback);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($checkpointCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,8 +121,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
public function handlePlayerFinishCallback(array $callback) {
|
||||
$data = $callback[1];
|
||||
$login = $data[1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@@ -141,7 +134,6 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
$finishCallback->setPlayer($player);
|
||||
$finishCallback->time = (int)$data[2];
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback($finishCallback);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($finishCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ class CommandManager implements CallbackListener {
|
||||
$this->helpManager = new HelpManager($this->maniaControl);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handleChatCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handleChatCallback');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,8 +163,7 @@ class CommandManager implements CallbackListener {
|
||||
|
||||
// Check for valid player
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,22 +38,17 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle ManiaControl OnInit Callback
|
||||
*/
|
||||
public function handleOnInit() {
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('help', $this, 'command_playerHelp', false, 'Shows all commands in chat.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('helpall', $this, 'command_playerHelpAll', false, 'Shows all commands in ManiaLink with description.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('help', $this, 'command_adminHelp', true, 'Shows all admin commands in chat.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('helpall', $this, 'command_adminHelpAll', true, 'Shows all admin commands in ManiaLink with description.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('help', $this, 'command_playerHelp', false, 'Shows all commands in chat.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('helpall', $this, 'command_playerHelpAll', false, 'Shows all commands in ManiaLink with description.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('help', $this, 'command_adminHelp', true, 'Shows all admin commands in chat.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('helpall', $this, 'command_adminHelpAll', true, 'Shows all admin commands in ManiaLink with description.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +79,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$message .= $command['Name'] . ',';
|
||||
}
|
||||
$message = substr($message, 0, -1);
|
||||
$this->maniaControl->getChat()
|
||||
->sendChat($message, $player);
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +110,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$message .= $command['Name'] . ',';
|
||||
}
|
||||
$message = substr($message, 0, -1);
|
||||
$this->maniaControl->getChat()
|
||||
->sendChat($message, $player);
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,12 +161,8 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
* @param mixed $player
|
||||
*/
|
||||
private function showHelpAllList(array $commands, $player) {
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
// create manialink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@@ -182,9 +171,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@@ -192,9 +179,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$posY = $height / 2;
|
||||
|
||||
//Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@@ -202,8 +187,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 5);
|
||||
$array = array('Command' => $posX + 5, 'Description' => $posX + 50);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
|
||||
$index = 1;
|
||||
$posY -= 10;
|
||||
@@ -230,8 +214,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
}
|
||||
|
||||
$array = array($command['Name'] => $posX + 5, $command['Description'] => $posX + 50);
|
||||
$labels = $this->maniaControl->getManialinkManager()
|
||||
->labelLine($playerFrame, $array);
|
||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
|
||||
|
||||
$label = $labels[0];
|
||||
$label->setWidth(40);
|
||||
@@ -241,8 +224,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'HelpAllList');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'HelpAllList');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,36 +70,24 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
$this->addActionsMenuItem();
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_POSX, 0.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_POSY, 3.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_WIDTH, 170.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_HEIGHT, 81.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_STYLE, Quad_BgRaceScore2::STYLE);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSX, 0.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSY, 3.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_WIDTH, 170.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_HEIGHT, 81.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_STYLE, Quad_BgRaceScore2::STYLE);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_OPEN_CONFIGURATOR, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_OPEN_CONFIGURATOR, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
|
||||
// Page answers
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_TOGGLEMENU, $this, 'handleToggleMenuAction');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_SAVECONFIG, $this, 'handleSaveConfigAction');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_TOGGLEMENU, $this, 'handleToggleMenuAction');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SAVECONFIG, $this, 'handleSaveConfigAction');
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
|
||||
// Create server options menu
|
||||
$this->serverOptionsMenu = new ServerOptionsMenu($maniaControl);
|
||||
@@ -118,8 +106,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
$this->addMenu($this->maniaControlSettings);
|
||||
|
||||
// Chat commands
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('config', $this, 'handleConfigCommand', true, 'Loads Config panel.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('config', $this, 'handleConfigCommand', true, 'Loads Config panel.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,10 +114,8 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
*/
|
||||
private function addActionsMenuItem() {
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools)
|
||||
->setAction(self::ACTION_TOGGLEMENU);
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addAdminMenuItem($itemQuad, 100, 'Settings');
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools)->setAction(self::ACTION_TOGGLEMENU);
|
||||
$this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad, 100, 'Settings');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,11 +134,9 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleConfigCommand(array $callback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -171,8 +154,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
$menuId = $this->getMenuId($menuId->getTitle());
|
||||
}
|
||||
$manialink = $this->buildManialink($menuId, $player);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($manialink, $player, self::MENU_NAME);
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($manialink, $player, self::MENU_NAME);
|
||||
$player->setCache($this, self::CACHE_MENU_SHOWN, true);
|
||||
}
|
||||
|
||||
@@ -201,18 +183,12 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
private function buildManialink($menuIdShown = 0, Player $player = null) {
|
||||
$menuPosX = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$menuPosY = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$menuWidth = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_WIDTH);
|
||||
$menuHeight = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_HEIGHT);
|
||||
$quadStyle = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_STYLE);
|
||||
$quadSubstyle = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_SUBSTYLE);
|
||||
$menuPosX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$menuPosY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$menuWidth = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_WIDTH);
|
||||
$menuHeight = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_HEIGHT);
|
||||
$quadStyle = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_STYLE);
|
||||
$quadSubstyle = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_SUBSTYLE);
|
||||
|
||||
$menuListWidth = $menuWidth * 0.3;
|
||||
$menuItemHeight = 10.;
|
||||
@@ -227,9 +203,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$frame->add($backgroundQuad);
|
||||
$backgroundQuad->setZ(-10)
|
||||
->setSize($menuWidth, $menuHeight)
|
||||
->setStyles($quadStyle, $quadSubstyle);
|
||||
$backgroundQuad->setZ(-10)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
$menuItemsFrame = new Frame();
|
||||
$frame->add($menuItemsFrame);
|
||||
@@ -238,8 +212,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
$itemsBackgroundQuad = new Quad();
|
||||
$menuItemsFrame->add($itemsBackgroundQuad);
|
||||
$backgroundQuad->setZ(-9);
|
||||
$itemsBackgroundQuad->setSize($menuListWidth, $menuHeight)
|
||||
->setStyles($quadStyle, $quadSubstyle);
|
||||
$itemsBackgroundQuad->setSize($menuListWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
$menusFrame = new Frame();
|
||||
$frame->add($menusFrame);
|
||||
@@ -254,11 +227,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
// Add title
|
||||
$menuItemLabel = new Label_Text();
|
||||
$menuItemsFrame->add($menuItemLabel);
|
||||
$menuItemLabel->setY($menuItemY)
|
||||
->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9)
|
||||
->setStyle($menuItemLabel::STYLE_TextCardRaceRank)
|
||||
->setText($menu->getTitle())
|
||||
->setAction(self::ACTION_SELECTMENU . $menuId);
|
||||
$menuItemLabel->setY($menuItemY)->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9)->setStyle($menuItemLabel::STYLE_TextCardRaceRank)->setText($menu->getTitle())->setAction(self::ACTION_SELECTMENU . $menuId);
|
||||
|
||||
// Show the menu
|
||||
if ($menuId === $menuIdShown) {
|
||||
@@ -266,8 +235,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
if ($menuControl) {
|
||||
$menusFrame->add($menuControl);
|
||||
} else {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error loading Menu!', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error loading Menu!', $player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,32 +246,17 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
// Add Close Quad (X)
|
||||
$closeQuad = new Quad_Icons64x64_1();
|
||||
$frame->add($closeQuad);
|
||||
$closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3)
|
||||
->setSize(6, 6)
|
||||
->setSubStyle($closeQuad::SUBSTYLE_QuitRace)
|
||||
->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||
$closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3)->setSize(6, 6)->setSubStyle($closeQuad::SUBSTYLE_QuitRace)->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||
|
||||
// Add close button
|
||||
$closeButton = new Label_Text();
|
||||
$frame->add($closeButton);
|
||||
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43)
|
||||
->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)
|
||||
->setStyle($closeButton::STYLE_TextButtonNavBack)
|
||||
->setTextPrefix('$999')
|
||||
->setTranslate(true)
|
||||
->setText('Close')
|
||||
->setAction(self::ACTION_TOGGLEMENU);
|
||||
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($closeButton::STYLE_TextButtonNavBack)->setTextPrefix('$999')->setTranslate(true)->setText('Close')->setAction(self::ACTION_TOGGLEMENU);
|
||||
|
||||
// Add save button
|
||||
$saveButton = new Label_Text();
|
||||
$frame->add($saveButton);
|
||||
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43)
|
||||
->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)
|
||||
->setStyle($saveButton::STYLE_TextButtonNavBack)
|
||||
->setTextPrefix('$0f5')
|
||||
->setTranslate(true)
|
||||
->setText('Save')
|
||||
->setAction(self::ACTION_SAVECONFIG);
|
||||
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($saveButton::STYLE_TextButtonNavBack)->setTextPrefix('$0f5')->setTranslate(true)->setText('Save')->setAction(self::ACTION_SAVECONFIG);
|
||||
|
||||
return $manialink;
|
||||
}
|
||||
@@ -338,8 +291,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
*/
|
||||
public function hideMenu(Player $player) {
|
||||
$this->closeWidget($player);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->closeWidget($player);
|
||||
$this->maniaControl->getManialinkManager()->closeWidget($player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,8 +340,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
}
|
||||
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
if ($player) {
|
||||
$actionArray = explode('.', $callback[1][2]);
|
||||
|
||||
@@ -52,12 +52,10 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +87,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @return \FML\Controls\Frame
|
||||
*/
|
||||
private function getMenuSettingsForClass($settingClass, $width, $height, Script $script, Player $player) {
|
||||
$settings = $this->maniaControl->getSettingManager()
|
||||
->getSettingsByClass($settingClass);
|
||||
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
||||
|
||||
$paging = new Paging();
|
||||
$script->addFeature($paging);
|
||||
@@ -217,8 +214,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @return \FML\Controls\Frame
|
||||
*/
|
||||
private function getMenuSettingClasses($width, $height, Script $script, Player $player) {
|
||||
$settingClasses = $this->maniaControl->getSettingManager()
|
||||
->getSettingClasses(true);
|
||||
$settingClasses = $this->maniaControl->getSettingManager()->getSettingClasses(true);
|
||||
|
||||
$paging = new Paging();
|
||||
$script->addFeature($paging);
|
||||
@@ -301,26 +297,20 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
if ($actionId === self::ACTION_SETTINGCLASS_BACK) {
|
||||
// Back to classes list
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$player->destroyCache($this, self::CACHE_CLASS_OPENED);
|
||||
$menuId = $this->maniaControl->getConfigurator()
|
||||
->getMenuId($this);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $menuId);
|
||||
$menuId = $this->maniaControl->getConfigurator()->getMenuId($this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $menuId);
|
||||
} else if (strpos($actionId, self::ACTION_PREFIX_SETTINGCLASS) === 0) {
|
||||
// Setting class selected
|
||||
$settingClass = substr($actionId, strlen(self::ACTION_PREFIX_SETTINGCLASS));
|
||||
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$player->setCache($this, self::CACHE_CLASS_OPENED, $settingClass);
|
||||
|
||||
$menuId = $this->maniaControl->getConfigurator()
|
||||
->getMenuId($this);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $menuId);
|
||||
$menuId = $this->maniaControl->getConfigurator()->getMenuId($this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $menuId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,11 +318,9 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||
*/
|
||||
public function saveConfigData(array $configData, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) {
|
||||
@@ -343,8 +331,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
foreach ($configData[3] as $settingData) {
|
||||
$settingIndex = (int)substr($settingData['Name'], $prefixLength);
|
||||
$settingObject = $this->maniaControl->getSettingManager()
|
||||
->getSettingObjectByIndex($settingIndex);
|
||||
$settingObject = $this->maniaControl->getSettingManager()->getSettingObjectByIndex($settingIndex);
|
||||
if (!$settingObject) {
|
||||
continue;
|
||||
}
|
||||
@@ -354,15 +341,12 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
$settingObject->value = $settingData['Value'];
|
||||
$this->maniaControl->getSettingManager()
|
||||
->saveSetting($settingObject);
|
||||
$this->maniaControl->getSettingManager()->saveSetting($settingObject);
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Settings saved!', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess('Settings saved!', $player);
|
||||
|
||||
// Reopen the Menu
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,18 +53,14 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$this->initTables();
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::BEGINMAP, $this, 'onBeginMap');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'onBeginMap');
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN, false);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN, false);
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +69,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @return boolean
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_SCRIPT_SETTINGS . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`serverIndex` int(11) NOT NULL,
|
||||
@@ -119,14 +114,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
*/
|
||||
public function loadSettingsFromDatabase() {
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->getClient()
|
||||
->getModeScriptSettings();
|
||||
$scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings();
|
||||
} catch (GameModeException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$serverIndex = $this->maniaControl->getServer()->index;
|
||||
$query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "`
|
||||
WHERE serverIndex = {$serverIndex};";
|
||||
@@ -149,16 +142,14 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->maniaControl->getClient()
|
||||
->setModeScriptSettings($loadedSettings);
|
||||
return $this->maniaControl->getClient()->setModeScriptSettings($loadedSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Begin Map Callback
|
||||
*/
|
||||
public function onBeginMap() {
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN)
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN)
|
||||
) {
|
||||
$this->loadSettingsFromDatabase();
|
||||
}
|
||||
@@ -173,8 +164,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$frame = new Frame();
|
||||
|
||||
try {
|
||||
$scriptInfo = $this->maniaControl->getClient()
|
||||
->getModeScriptInfo();
|
||||
$scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo();
|
||||
} catch (GameModeException $e) {
|
||||
$label = new Label();
|
||||
$frame->add($label);
|
||||
@@ -185,8 +175,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$scriptParams = $scriptInfo->paramDescs;
|
||||
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->getClient()
|
||||
->getModeScriptSettings();
|
||||
$scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings();
|
||||
} catch (GameModeException $e) {
|
||||
}
|
||||
|
||||
@@ -293,11 +282,9 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||
*/
|
||||
public function saveConfigData(array $configData, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) {
|
||||
@@ -305,8 +292,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->getClient()
|
||||
->getModeScriptSettings();
|
||||
$scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings();
|
||||
} catch (GameModeException $e) {
|
||||
return;
|
||||
}
|
||||
@@ -332,16 +318,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
$success = $this->applyNewScriptSettings($newSettings, $player);
|
||||
if ($success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Script Settings saved!', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess('Script Settings saved!', $player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Script Settings Saving failed!', $player);
|
||||
$this->maniaControl->getChat()->sendError('Script Settings Saving failed!', $player);
|
||||
}
|
||||
|
||||
// Reopen the Menu
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,12 +339,10 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->maniaControl->getClient()
|
||||
->setModeScriptSettings($newSettings);
|
||||
$this->maniaControl->getClient()->setModeScriptSettings($newSettings);
|
||||
|
||||
// Save Settings into Database
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "INSERT INTO `" . self::TABLE_SCRIPT_SETTINGS . "` (
|
||||
`serverIndex`,
|
||||
`settingName`,
|
||||
@@ -382,8 +363,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
// Notifications
|
||||
$settingsCount = count($newSettings);
|
||||
$settingIndex = 0;
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($player);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player);
|
||||
$chatMessage = '$ff0' . $title . ' ' . $player->getEscapedNickname() . ' set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
|
||||
foreach ($newSettings as $setting => $value) {
|
||||
$chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 ';
|
||||
@@ -402,19 +382,16 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_SCRIPTSETTING_CHANGED, $setting, $value);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SCRIPTSETTING_CHANGED, $setting, $value);
|
||||
|
||||
$settingIndex++;
|
||||
}
|
||||
$statement->close();
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_SCRIPTSETTINGS_CHANGED);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SCRIPTSETTINGS_CHANGED);
|
||||
|
||||
$chatMessage .= '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,15 +49,13 @@ class Database implements TimerListener {
|
||||
$message = "Couldn't connect to Database: '{$connectError}'";
|
||||
$this->maniaControl->quit($message, true);
|
||||
}
|
||||
$this->getMysqli()
|
||||
->set_charset("utf8");
|
||||
$this->getMysqli()->set_charset("utf8");
|
||||
|
||||
$this->initDatabase();
|
||||
$this->optimizeTables();
|
||||
|
||||
// Register Method which checks the Database Connection every 5 seconds
|
||||
$this->maniaControl->getTimerManager()
|
||||
->registerTimerListening($this, 'checkConnection', 5000);
|
||||
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'checkConnection', 5000);
|
||||
|
||||
// Children
|
||||
$this->migrationHelper = new MigrationHelper($maniaControl);
|
||||
@@ -67,8 +65,7 @@ class Database implements TimerListener {
|
||||
* Load the Database Config
|
||||
*/
|
||||
private function loadConfig() {
|
||||
$databaseElements = $this->maniaControl->getConfig()
|
||||
->xpath('database');
|
||||
$databaseElements = $this->maniaControl->getConfig()->xpath('database');
|
||||
if (!$databaseElements) {
|
||||
$this->maniaControl->quit('No Database configured!', true);
|
||||
}
|
||||
@@ -127,26 +124,22 @@ class Database implements TimerListener {
|
||||
*/
|
||||
private function initDatabase() {
|
||||
// Try to connect
|
||||
$result = $this->getMysqli()
|
||||
->select_db($this->config->name);
|
||||
$result = $this->getMysqli()->select_db($this->config->name);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
Logger::logInfo("Database '{$this->config->name}' doesn't exist! Trying to create it...");
|
||||
|
||||
// Create database
|
||||
$databaseQuery = "CREATE DATABASE " . $this->getMysqli()
|
||||
->escape_string($this->config->name) . ";";
|
||||
$this->getMysqli()
|
||||
->query($databaseQuery);
|
||||
$databaseQuery = "CREATE DATABASE " . $this->getMysqli()->escape_string($this->config->name) . ";";
|
||||
$this->getMysqli()->query($databaseQuery);
|
||||
if ($this->getMysqli()->error) {
|
||||
$this->maniaControl->quit($this->getMysqli()->error, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Connect to new database
|
||||
$this->getMysqli()
|
||||
->select_db($this->config->name);
|
||||
$this->getMysqli()->select_db($this->config->name);
|
||||
if ($error = $this->getMysqli()->error) {
|
||||
$message = "Couldn't select database '{$this->config->name}'. {$error}";
|
||||
$this->maniaControl->quit($message, true);
|
||||
@@ -163,8 +156,7 @@ class Database implements TimerListener {
|
||||
*/
|
||||
private function optimizeTables() {
|
||||
$showQuery = 'SHOW TABLES;';
|
||||
$result = $this->getMysqli()
|
||||
->query($showQuery);
|
||||
$result = $this->getMysqli()->query($showQuery);
|
||||
if ($error = $this->getMysqli()->error) {
|
||||
Logger::logError($error);
|
||||
return false;
|
||||
@@ -186,8 +178,7 @@ class Database implements TimerListener {
|
||||
}
|
||||
$result->free();
|
||||
$optimizeQuery .= ';';
|
||||
$this->getMysqli()
|
||||
->query($optimizeQuery);
|
||||
$this->getMysqli()->query($optimizeQuery);
|
||||
if ($error = $this->getMysqli()->error) {
|
||||
Logger::logError($error);
|
||||
return false;
|
||||
@@ -227,8 +218,7 @@ class Database implements TimerListener {
|
||||
*/
|
||||
public function checkConnection() {
|
||||
if (!$this->getMysqli()
|
||||
|| !$this->getMysqli()
|
||||
->ping()
|
||||
|| !$this->getMysqli()->ping()
|
||||
) {
|
||||
$this->maniaControl->quit('The MySQL Server has gone away!', true);
|
||||
}
|
||||
@@ -239,8 +229,7 @@ class Database implements TimerListener {
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->getMysqli() && !$this->getMysqli()->connect_error) {
|
||||
$this->getMysqli()
|
||||
->close();
|
||||
$this->getMysqli()->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,7 @@ class MigrationHelper {
|
||||
$sourceClass = ClassUtil::getClass($sourceClass);
|
||||
$targetClass = ClassUtil::getClass($targetClass);
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
$query = "INSERT IGNORE INTO `" . SettingManager::TABLE_SETTINGS . "`
|
||||
(`class`, `setting`, `type`, `value`, `default`)
|
||||
|
||||
@@ -47,8 +47,7 @@ class ErrorHandler {
|
||||
* Initialize error handler features
|
||||
*/
|
||||
public function init() {
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_RESTART_ON_EXCEPTION, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RESTART_ON_EXCEPTION, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,8 +125,7 @@ class ErrorHandler {
|
||||
if ($pluginId > 0) {
|
||||
$report['PluginId'] = $pluginId;
|
||||
if ($isFatalError) {
|
||||
$this->maniaControl->getPluginManager()
|
||||
->deactivatePlugin($sourceClass);
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,10 +140,8 @@ class ErrorHandler {
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager() && $this->maniaControl->getUpdateManager()) {
|
||||
$report['UpdateChannel'] = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$report['ManiaControlVersion'] = ManiaControl::VERSION . ' ' . $this->maniaControl->getUpdateManager()
|
||||
->getNightlyBuildDate();
|
||||
$report['UpdateChannel'] = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$report['ManiaControlVersion'] = ManiaControl::VERSION . ' ' . $this->maniaControl->getUpdateManager()->getNightlyBuildDate();
|
||||
} else {
|
||||
$report['ManiaControlVersion'] = ManiaControl::VERSION;
|
||||
}
|
||||
@@ -399,20 +395,17 @@ class ErrorHandler {
|
||||
|
||||
if ($this->maniaControl->getCallbackManager()) {
|
||||
// OnShutdown callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONSHUTDOWN);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSHUTDOWN);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getChat()) {
|
||||
// Announce quit
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation('ManiaControl shutting down.');
|
||||
$this->maniaControl->getChat()->sendInformation('ManiaControl shutting down.');
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getClient()) {
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->sendHideManialinkPage();
|
||||
$this->maniaControl->getClient()->sendHideManialinkPage();
|
||||
} catch (TransportException $e) {
|
||||
$this->handleException($e, false);
|
||||
}
|
||||
@@ -460,10 +453,8 @@ class ErrorHandler {
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager() && $this->maniaControl->getUpdateManager()) {
|
||||
$report['UpdateChannel'] = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$report['ManiaControlVersion'] = ManiaControl::VERSION . ' #' . $this->maniaControl->getUpdateManager()
|
||||
->getNightlyBuildDate();
|
||||
$report['UpdateChannel'] = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
$report['ManiaControlVersion'] = ManiaControl::VERSION . ' #' . $this->maniaControl->getUpdateManager()->getNightlyBuildDate();
|
||||
} else {
|
||||
$report['ManiaControlVersion'] = ManiaControl::VERSION;
|
||||
}
|
||||
@@ -499,8 +490,7 @@ class ErrorHandler {
|
||||
if (!$this->maniaControl || !$this->maniaControl->getSettingManager() || DEV_MODE) {
|
||||
return false;
|
||||
}
|
||||
$setting = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_RESTART_ON_EXCEPTION, true);
|
||||
$setting = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RESTART_ON_EXCEPTION, true);
|
||||
return $setting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@ class AsynchronousFileReader {
|
||||
|
||||
public static function newRequestTest($url) {
|
||||
$request = new Request($url);
|
||||
$request->getOptions()
|
||||
->set(CURLOPT_TIMEOUT, 60)
|
||||
->set(CURLOPT_HEADER, false) // don't display response header
|
||||
$request->getOptions()->set(CURLOPT_TIMEOUT, 60)->set(CURLOPT_HEADER, false) // don't display response header
|
||||
->set(CURLOPT_CRLF, true) // linux line feed
|
||||
->set(CURLOPT_ENCODING, '') // accept encoding
|
||||
->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // user-agent
|
||||
@@ -78,16 +76,14 @@ class AsynchronousFileReader {
|
||||
}
|
||||
|
||||
$request = $this->newRequest($url);
|
||||
$request->getOptions()
|
||||
->set(CURLOPT_AUTOREFERER, true) // accept link reference
|
||||
$request->getOptions()->set(CURLOPT_AUTOREFERER, true) // accept link reference
|
||||
->set(CURLOPT_HTTPHEADER, $headers); // headers
|
||||
|
||||
$request->addListener('complete', function (Event $event) use (&$function) {
|
||||
$error = null;
|
||||
$content = null;
|
||||
if ($event->response->hasError()) {
|
||||
$error = $event->response->getError()
|
||||
->getMessage();
|
||||
$error = $event->response->getError()->getMessage();
|
||||
} else {
|
||||
$content = $event->response->getContent();
|
||||
}
|
||||
@@ -105,9 +101,7 @@ class AsynchronousFileReader {
|
||||
*/
|
||||
protected function newRequest($url) {
|
||||
$request = new Request($url);
|
||||
$request->getOptions()
|
||||
->set(CURLOPT_TIMEOUT, 60)
|
||||
->set(CURLOPT_HEADER, false) // don't display response header
|
||||
$request->getOptions()->set(CURLOPT_TIMEOUT, 60)->set(CURLOPT_HEADER, false) // don't display response header
|
||||
->set(CURLOPT_CRLF, true) // linux line feed
|
||||
->set(CURLOPT_ENCODING, '') // accept encoding
|
||||
->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // user-agent
|
||||
@@ -140,8 +134,7 @@ class AsynchronousFileReader {
|
||||
array_push($headers, 'Content-Encoding: gzip');
|
||||
}
|
||||
|
||||
$request->getOptions()
|
||||
->set(CURLOPT_POST, true) // post method
|
||||
$request->getOptions()->set(CURLOPT_POST, true) // post method
|
||||
->set(CURLOPT_POSTFIELDS, $content) // post content field
|
||||
->set(CURLOPT_HTTPHEADER, $headers) // headers
|
||||
;
|
||||
@@ -149,8 +142,7 @@ class AsynchronousFileReader {
|
||||
$error = null;
|
||||
$content = null;
|
||||
if ($event->response->hasError()) {
|
||||
$error = $event->response->getError()
|
||||
->getMessage();
|
||||
$error = $event->response->getError()->getMessage();
|
||||
} else {
|
||||
$content = $event->response->getContent();
|
||||
}
|
||||
@@ -186,8 +178,7 @@ class AsynchronousFileReader {
|
||||
}
|
||||
|
||||
$request = $this->newRequest($url);
|
||||
$request->getOptions()
|
||||
->set(CURLOPT_POST, true) // post method
|
||||
$request->getOptions()->set(CURLOPT_POST, true) // post method
|
||||
->set(CURLOPT_POSTFIELDS, $content) // post content field
|
||||
->set(CURLOPT_HTTPHEADER, $headers) // headers
|
||||
;
|
||||
@@ -195,8 +186,7 @@ class AsynchronousFileReader {
|
||||
$error = null;
|
||||
$content = null;
|
||||
if ($event->response->hasError()) {
|
||||
$error = $event->response->getError()
|
||||
->getMessage();
|
||||
$error = $event->response->getError()->getMessage();
|
||||
} else {
|
||||
$content = $event->response->getContent();
|
||||
}
|
||||
|
||||
@@ -155,26 +155,19 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
$this->pluginManager = new PluginManager($this);
|
||||
$this->updateManager = new UpdateManager($this);
|
||||
|
||||
$this->getErrorHandler()
|
||||
->init();
|
||||
$this->getErrorHandler()->init();
|
||||
|
||||
// Permissions
|
||||
$this->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_RESTART, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_RESTART, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
|
||||
// Commands
|
||||
$this->getCommandManager()
|
||||
->registerCommandListener('version', $this, 'commandVersion', false, 'Shows ManiaControl version.');
|
||||
$this->getCommandManager()
|
||||
->registerCommandListener('restart', $this, 'commandRestart', true, 'Restarts ManiaControl.');
|
||||
$this->getCommandManager()
|
||||
->registerCommandListener('shutdown', $this, 'commandShutdown', true, 'Shuts ManiaControl down.');
|
||||
$this->getCommandManager()->registerCommandListener('version', $this, 'commandVersion', false, 'Shows ManiaControl version.');
|
||||
$this->getCommandManager()->registerCommandListener('restart', $this, 'commandRestart', true, 'Restarts ManiaControl.');
|
||||
$this->getCommandManager()->registerCommandListener('shutdown', $this, 'commandShutdown', true, 'Shuts ManiaControl down.');
|
||||
|
||||
// Check connection every 30 seconds
|
||||
$this->getTimerManager()
|
||||
->registerTimerListening($this, 'checkConnection', 1000 * 30);
|
||||
$this->getTimerManager()->registerTimerListening($this, 'checkConnection', 1000 * 30);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,11 +403,9 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
* Check connection
|
||||
*/
|
||||
public function checkConnection() {
|
||||
if ($this->getClient()
|
||||
->getIdleTime() > 180
|
||||
if ($this->getClient()->getIdleTime() > 180
|
||||
) {
|
||||
$this->getClient()
|
||||
->getServerName();
|
||||
$this->getClient()->getServerName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,8 +417,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
*/
|
||||
public function commandVersion(array $chatCallback, Player $player) {
|
||||
$message = 'This server is using ManiaControl v' . ManiaControl::VERSION . '!';
|
||||
$this->getChat()
|
||||
->sendInformation($message, $player);
|
||||
$this->getChat()->sendInformation($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,11 +427,9 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function commandRestart(array $chatCallback, Player $player) {
|
||||
if (!$this->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_RESTART)
|
||||
if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_RESTART)
|
||||
) {
|
||||
$this->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$this->restart("ManiaControl Restart requested by '{$player->login}'!");
|
||||
@@ -454,21 +442,18 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
*/
|
||||
public function restart($message = null) {
|
||||
// Shutdown callback
|
||||
$this->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONSHUTDOWN);
|
||||
$this->getCallbackManager()->triggerCallback(Callbacks::ONSHUTDOWN);
|
||||
|
||||
// Announce restart
|
||||
if ($message) {
|
||||
Logger::log($message);
|
||||
}
|
||||
$this->getChat()
|
||||
->sendInformation('Restarting ManiaControl...');
|
||||
$this->getChat()->sendInformation('Restarting ManiaControl...');
|
||||
Logger::log('Restarting ManiaControl!');
|
||||
|
||||
// Hide widgets
|
||||
if ($this->getClient()) {
|
||||
$this->getClient()
|
||||
->sendHideManialinkPage();
|
||||
$this->getClient()->sendHideManialinkPage();
|
||||
}
|
||||
|
||||
// Start new instance
|
||||
@@ -485,11 +470,9 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function commandShutdown(array $chat, Player $player) {
|
||||
if (!$this->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_SHUTDOWN)
|
||||
if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_SHUTDOWN)
|
||||
) {
|
||||
$this->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$this->requestQuit("ManiaControl Shutdown requested by '{$player->login}'!");
|
||||
@@ -518,37 +501,28 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
}
|
||||
|
||||
// Check if the version of the server is high enough
|
||||
$version = $this->getClient()
|
||||
->getVersion();
|
||||
$version = $this->getClient()->getVersion();
|
||||
if ($version->build < self::MIN_DEDIVERSION) {
|
||||
$this->quit("The Server has Version '{$version->build}', while at least '" . self::MIN_DEDIVERSION . "' is required!", true);
|
||||
}
|
||||
|
||||
// Listen for shutdown
|
||||
$this->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_SERVERSTOP, $this, 'handleServerStopCallback');
|
||||
$this->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_SERVERSTOP, $this, 'handleServerStopCallback');
|
||||
|
||||
// OnInit callback
|
||||
$this->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ONINIT);
|
||||
$this->getCallbackManager()->triggerCallback(Callbacks::ONINIT);
|
||||
|
||||
// Load plugins
|
||||
$this->getPluginManager()
|
||||
->loadPlugins();
|
||||
$this->getUpdateManager()
|
||||
->getPluginUpdateManager()
|
||||
->checkPluginsUpdate();
|
||||
$this->getPluginManager()->loadPlugins();
|
||||
$this->getUpdateManager()->getPluginUpdateManager()->checkPluginsUpdate();
|
||||
|
||||
// AfterInit callback
|
||||
$this->getCallbackManager()
|
||||
->triggerCallback(Callbacks::AFTERINIT);
|
||||
$this->getCallbackManager()->triggerCallback(Callbacks::AFTERINIT);
|
||||
|
||||
// Loading finished
|
||||
Logger::log('Loading completed!');
|
||||
Logger::log('Link: ' . $this->getServer()
|
||||
->getJoinLink());
|
||||
$this->getChat()
|
||||
->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!');
|
||||
Logger::log('Link: ' . $this->getServer()->getJoinLink());
|
||||
$this->getChat()->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!');
|
||||
|
||||
// Main loop
|
||||
while (!$this->requestQuitMessage) {
|
||||
@@ -564,8 +538,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
*/
|
||||
private function connect() {
|
||||
// Load remote client
|
||||
$serverConfig = $this->getServer()
|
||||
->loadConfig();
|
||||
$serverConfig = $this->getServer()->loadConfig();
|
||||
|
||||
Logger::log("Connecting to Server at {$serverConfig->host}:{$serverConfig->port}...");
|
||||
|
||||
@@ -580,12 +553,10 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
}
|
||||
|
||||
// Enable callback system
|
||||
$this->getClient()
|
||||
->enableCallbacks(true);
|
||||
$this->getClient()->enableCallbacks(true);
|
||||
|
||||
// Wait for server to be ready
|
||||
if (!$this->getServer()
|
||||
->waitForStatus(4)
|
||||
if (!$this->getServer()->waitForStatus(4)
|
||||
) {
|
||||
$this->quit("Server couldn't get ready!");
|
||||
}
|
||||
@@ -594,13 +565,10 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
Logger::log('Server Connection successfully established!');
|
||||
|
||||
// Hide old widgets
|
||||
$this->getClient()
|
||||
->sendHideManialinkPage();
|
||||
$this->getClient()->sendHideManialinkPage();
|
||||
|
||||
// Enable script callbacks
|
||||
$this->getServer()
|
||||
->getScriptManager()
|
||||
->enableScriptCallbacks();
|
||||
$this->getServer()->getScriptManager()->enableScriptCallbacks();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,16 +581,14 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
|
||||
set_time_limit(self::SCRIPT_TIMEOUT);
|
||||
|
||||
try {
|
||||
$this->getCallbackManager()
|
||||
->manageCallbacks();
|
||||
$this->getCallbackManager()->manageCallbacks();
|
||||
} catch (TransportException $e) {
|
||||
Logger::logError('Connection interrupted!');
|
||||
$this->quit($e->getMessage(), true);
|
||||
}
|
||||
|
||||
// Manage FileReader
|
||||
$this->getFileReader()
|
||||
->appendData();
|
||||
$this->getFileReader()->appendData();
|
||||
|
||||
// Yield for next tick
|
||||
$loopEnd = microtime(true);
|
||||
|
||||
@@ -58,17 +58,12 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// 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(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->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showList');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +80,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
|
||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$mapId = (int)$actionArray[2];
|
||||
|
||||
switch ($action) {
|
||||
@@ -95,8 +89,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$this->showList($callback, $player);
|
||||
break;
|
||||
case self::ACTION_ADD_MAP:
|
||||
$this->maniaControl->getMapManager()
|
||||
->addMapFromMx($mapId, $player->login);
|
||||
$this->maniaControl->getMapManager()->addMapFromMx($mapId, $player->login);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -138,16 +131,13 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
}
|
||||
|
||||
// search for matching maps
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMXManager()
|
||||
->fetchMapsAsync(function (array $maps) use (&$player) {
|
||||
if (!$maps) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('No maps found, or MX is down!', $player->login);
|
||||
return;
|
||||
}
|
||||
$this->showManiaExchangeList($maps, $player);
|
||||
}, $searchString, $author, $environment);
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchMapsAsync(function (array $maps) use (&$player) {
|
||||
if (!$maps) {
|
||||
$this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login);
|
||||
return;
|
||||
}
|
||||
$this->showManiaExchangeList($maps, $player);
|
||||
}, $searchString, $author, $environment);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,12 +149,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
*/
|
||||
private function showManiaExchangeList(array $maps, Player $player) {
|
||||
// Start offsets
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$posX = -$width / 2;
|
||||
$posY = $height / 2;
|
||||
|
||||
@@ -175,15 +161,11 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
//Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@@ -191,8 +173,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 12);
|
||||
$array = array('$oId' => $posX + 3.5, '$oName' => $posX + 12.5, '$oAuthor' => $posX + 59, '$oKarma' => $posX + 85, '$oType' => $posX + 103, '$oMood' => $posX + 118, '$oLast Update' => $posX + 130);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
|
||||
$index = 0;
|
||||
$posY = $height / 2 - 16;
|
||||
@@ -221,8 +202,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
|
||||
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
||||
$array = array('$s' . $map->id => $posX + 3.5, '$s' . $map->name => $posX + 12.5, '$s' . $map->author => $posX + 59, '$s' . str_replace('Arena', '', $map->maptype) => $posX + 103, '$s' . $map->mood => $posX + 118, '$s' . $time => $posX + 130);
|
||||
$labels = $this->maniaControl->getManialinkManager()
|
||||
->labelLine($mapFrame, $array);
|
||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
|
||||
$authorLabel = $labels[2];
|
||||
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
||||
|
||||
@@ -231,20 +211,15 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$mxQuad = new Quad();
|
||||
$mapFrame->add($mxQuad);
|
||||
$mxQuad->setSize(3, 3);
|
||||
$mxQuad->setImage($this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON));
|
||||
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$mxQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$mxQuad->setX($posX + 56);
|
||||
$mxQuad->setUrl($map->pageurl);
|
||||
$mxQuad->setZ(0.01);
|
||||
$description = 'View $<' . $map->name . '$> on Mania-Exchange';
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
) {
|
||||
$addQuad = new Quad_Icons64x64_1();
|
||||
$mapFrame->add($addQuad);
|
||||
@@ -352,8 +327,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$quad->setAction(self::ACTION_SEARCH_AUTHOR);
|
||||
|
||||
// render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'ManiaExchangeList');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'ManiaExchangeList');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,12 +81,10 @@ class ManiaExchangeManager {
|
||||
$maps = array($maps);
|
||||
} else {
|
||||
// Fetch Information for whole MapList
|
||||
$maps = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mapIdString = '';
|
||||
|
||||
// Fetch mx ids
|
||||
@@ -102,8 +100,7 @@ class ManiaExchangeManager {
|
||||
foreach ($maps as $map) {
|
||||
if (!$map) {
|
||||
// TODO: remove after resolving of error report about "non-object"
|
||||
$this->maniaControl->getErrorHandler()
|
||||
->triggerDebugNotice('Non-Object-Map', $map, $maps);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Non-Object-Map', $map, $maps);
|
||||
continue;
|
||||
}
|
||||
/** @var Map $map */
|
||||
@@ -156,41 +153,38 @@ class ManiaExchangeManager {
|
||||
*/
|
||||
public function fetchMaplistByMixedUidIdString($string) {
|
||||
// Get Title Prefix
|
||||
$titlePrefix = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame();
|
||||
$titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame();
|
||||
|
||||
// compile search URL
|
||||
$url = "http://api.mania-exchange.com/{$titlePrefix}/maps/?ids={$string}";
|
||||
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($mapInfo, $error) use ($titlePrefix, $url) {
|
||||
if ($error) {
|
||||
trigger_error("Error: '{$error}' for Url '{$url}'");
|
||||
return;
|
||||
}
|
||||
if (!$mapInfo) {
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use ($titlePrefix, $url) {
|
||||
if ($error) {
|
||||
trigger_error("Error: '{$error}' for Url '{$url}'");
|
||||
return;
|
||||
}
|
||||
if (!$mapInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mxMapList = json_decode($mapInfo);
|
||||
if ($mxMapList === null) {
|
||||
trigger_error("Can't decode searched JSON Data from Url '{$url}'");
|
||||
return;
|
||||
}
|
||||
$mxMapList = json_decode($mapInfo);
|
||||
if ($mxMapList === null) {
|
||||
trigger_error("Can't decode searched JSON Data from Url '{$url}'");
|
||||
return;
|
||||
}
|
||||
|
||||
$maps = array();
|
||||
foreach ($mxMapList as $map) {
|
||||
if ($map) {
|
||||
$mxMapObject = new MXMapInfo($titlePrefix, $map);
|
||||
if ($mxMapObject) {
|
||||
array_push($maps, $mxMapObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
$maps = array();
|
||||
foreach ($mxMapList as $map) {
|
||||
if ($map) {
|
||||
$mxMapObject = new MXMapInfo($titlePrefix, $map);
|
||||
if ($mxMapObject) {
|
||||
array_push($maps, $mxMapObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateMapObjectsWithManiaExchangeIds($maps);
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
$this->updateMapObjectsWithManiaExchangeIds($maps);
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,8 +193,7 @@ class ManiaExchangeManager {
|
||||
* @param array $mxMapInfos
|
||||
*/
|
||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
// Save map data
|
||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||
SET `mxid` = ?
|
||||
@@ -226,8 +219,7 @@ class ManiaExchangeManager {
|
||||
} else {
|
||||
$uid = $mxMapInfo->uid;
|
||||
}
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getMapByUid($uid);
|
||||
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
|
||||
if ($map) {
|
||||
// TODO: how does it come that $map can be empty here? we got an error report for that
|
||||
/** @var Map $map */
|
||||
@@ -254,28 +246,25 @@ class ManiaExchangeManager {
|
||||
*/
|
||||
public function fetchMapInfo($mapId, callable $function) {
|
||||
// Get Title Prefix
|
||||
$titlePrefix = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame();
|
||||
$titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame();
|
||||
|
||||
// compile search URL
|
||||
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $mapId;
|
||||
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
|
||||
$mxMapInfo = null;
|
||||
if ($error) {
|
||||
trigger_error($error);
|
||||
} else {
|
||||
$mxMapList = json_decode($mapInfo);
|
||||
if (!is_array($mxMapList)) {
|
||||
trigger_error('Cannot decode searched JSON data from ' . $url);
|
||||
} else if (!empty($mxMapList)) {
|
||||
$mxMapInfo = new MXMapInfo($titlePrefix, $mxMapList[0]);
|
||||
}
|
||||
}
|
||||
call_user_func($function, $mxMapInfo);
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
|
||||
$mxMapInfo = null;
|
||||
if ($error) {
|
||||
trigger_error($error);
|
||||
} else {
|
||||
$mxMapList = json_decode($mapInfo);
|
||||
if (!is_array($mxMapList)) {
|
||||
trigger_error('Cannot decode searched JSON data from ' . $url);
|
||||
} else if (!empty($mxMapList)) {
|
||||
$mxMapInfo = new MXMapInfo($titlePrefix, $mxMapList[0]);
|
||||
}
|
||||
}
|
||||
call_user_func($function, $mxMapInfo);
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,9 +293,7 @@ class ManiaExchangeManager {
|
||||
|
||||
// Get Title Id
|
||||
$titleId = $this->maniaControl->getServer()->titleId;
|
||||
$titlePrefix = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame();
|
||||
$titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame();
|
||||
|
||||
// compile search URL
|
||||
$url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on';
|
||||
@@ -332,43 +319,41 @@ class ManiaExchangeManager {
|
||||
|
||||
// Get MapTypes
|
||||
try {
|
||||
$scriptInfos = $this->maniaControl->getClient()
|
||||
->getModeScriptInfo();
|
||||
$scriptInfos = $this->maniaControl->getClient()->getModeScriptInfo();
|
||||
$mapTypes = $scriptInfos->compatibleMapTypes;
|
||||
$url .= '&mtype=' . $mapTypes;
|
||||
} catch (GameModeException $e) {
|
||||
}
|
||||
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
||||
if ($error) {
|
||||
trigger_error($error);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
||||
if ($error) {
|
||||
trigger_error($error);
|
||||
return;
|
||||
}
|
||||
|
||||
$mxMapList = json_decode($mapInfo);
|
||||
$mxMapList = json_decode($mapInfo);
|
||||
|
||||
if (!isset($mxMapList->results)) {
|
||||
trigger_error('Cannot decode searched JSON data');
|
||||
return;
|
||||
}
|
||||
if (!isset($mxMapList->results)) {
|
||||
trigger_error('Cannot decode searched JSON data');
|
||||
return;
|
||||
}
|
||||
|
||||
$mxMapList = $mxMapList->results;
|
||||
$mxMapList = $mxMapList->results;
|
||||
|
||||
if ($mxMapList === null) {
|
||||
trigger_error('Cannot decode searched JSON data');
|
||||
return;
|
||||
}
|
||||
if ($mxMapList === null) {
|
||||
trigger_error('Cannot decode searched JSON data');
|
||||
return;
|
||||
}
|
||||
|
||||
$maps = array();
|
||||
foreach ($mxMapList as $map) {
|
||||
if (!empty($map)) {
|
||||
array_push($maps, new MXMapInfo($titlePrefix, $map));
|
||||
}
|
||||
}
|
||||
$maps = array();
|
||||
foreach ($mxMapList as $map) {
|
||||
if (!empty($map)) {
|
||||
array_push($maps, new MXMapInfo($titlePrefix, $map));
|
||||
}
|
||||
}
|
||||
|
||||
call_user_func($function, $maps);
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
call_user_func($function, $maps);
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,10 +41,8 @@ class CustomUIManager implements CallbackListener, TimerListener {
|
||||
$this->prepareManialink();
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getTimerManager()
|
||||
->registerTimerListening($this, 'handle1Second', 1000);
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,12 +70,10 @@ class CustomUIManager implements CallbackListener, TimerListener {
|
||||
*/
|
||||
public function updateManialink(Player $player = null) {
|
||||
if ($player) {
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($this->customUI, $player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->customUI, $player);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($this->customUI);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->customUI);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,10 +86,9 @@ class CustomUIManager implements CallbackListener, TimerListener {
|
||||
|
||||
//TODO: validate necessity
|
||||
//send it again after 500ms
|
||||
$this->maniaControl->getTimerManager()
|
||||
->registerOneTimeListening($this, function () use (&$player) {
|
||||
$this->updateManialink($player);
|
||||
}, 500);
|
||||
$this->maniaControl->getTimerManager()->registerOneTimeListening($this, function () use (&$player) {
|
||||
$this->updateManialink($player);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,10 +51,8 @@ class IconManager implements CallbackListener {
|
||||
$this->addDefaultIcons();
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +114,7 @@ class IconManager implements CallbackListener {
|
||||
}
|
||||
|
||||
// Send manialink
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($maniaLink, $player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,8 +66,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
|
||||
// Callbacks
|
||||
$this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET, $this, 'closeWidgetCallback');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,8 +175,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$actionId = $callback[1][2];
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
if (array_key_exists($actionId, $this->pageAnswerListeners) && is_array($this->pageAnswerListeners[$actionId])) {
|
||||
// Inform page answer listeners
|
||||
@@ -212,10 +210,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
// TODO make check by manialinkId, getter is needed to avoid uses on non main widgets
|
||||
$this->disableAltMenu($player);
|
||||
// Trigger callback
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($player);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_MAIN_WINDOW_OPENED, $player, $widgetName);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($player);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAIN_WINDOW_OPENED, $player, $widgetName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,17 +233,14 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
|
||||
try {
|
||||
if (!$logins) {
|
||||
return $this->maniaControl->getClient()
|
||||
->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
if (is_string($logins)) {
|
||||
$success = $this->maniaControl->getClient()
|
||||
->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||
$success = $this->maniaControl->getClient()->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||
return $success;
|
||||
}
|
||||
if ($logins instanceof Player) {
|
||||
$success = $this->maniaControl->getClient()
|
||||
->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||
$success = $this->maniaControl->getClient()->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||
return $success;
|
||||
}
|
||||
if (is_array($logins)) {
|
||||
@@ -276,8 +269,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
public function disableAltMenu($player) {
|
||||
$login = Player::parseLogin($player);
|
||||
try {
|
||||
$success = $this->maniaControl->getClient()
|
||||
->triggerModeScriptEvent('LibXmlRpc_DisableAltMenu', $login);
|
||||
$success = $this->maniaControl->getClient()->triggerModeScriptEvent('LibXmlRpc_DisableAltMenu', $login);
|
||||
} catch (GameModeException $e) {
|
||||
return false;
|
||||
}
|
||||
@@ -306,10 +298,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
$this->enableAltMenu($player);
|
||||
|
||||
// Trigger callback
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($player);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($player);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, $player);
|
||||
} else {
|
||||
$this->hideManialink($widgetId, $player);
|
||||
}
|
||||
@@ -341,8 +331,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
public function enableAltMenu($player) {
|
||||
$login = Player::parseLogin($player);
|
||||
try {
|
||||
$success = $this->maniaControl->getClient()
|
||||
->triggerModeScriptEvent('LibXmlRpc_EnableAltMenu', $login);
|
||||
$success = $this->maniaControl->getClient()->triggerModeScriptEvent('LibXmlRpc_EnableAltMenu', $login);
|
||||
} catch (GameModeException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,24 +50,16 @@ class StyleManager {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_LABEL_DEFAULT_STYLE, Label_Text::STYLE_TextTitle1);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_QUAD_DEFAULT_STYLE, Quad_Bgs1InRace::STYLE);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE, Quad_Bgs1InRace::SUBSTYLE_BgTitleShadow);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LABEL_DEFAULT_STYLE, Label_Text::STYLE_TextTitle1);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_QUAD_DEFAULT_STYLE, Quad_Bgs1InRace::STYLE);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE, Quad_Bgs1InRace::SUBSTYLE_BgTitleShadow);
|
||||
|
||||
// Main Widget
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE, Quad_BgRaceScore2::STYLE);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_LIST_WIDGETS_WIDTH, 150.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_LIST_WIDGETS_HEIGHT, 80.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_ICON_DEFAULT_OFFSET_SM, 20.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE, Quad_BgRaceScore2::STYLE);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LIST_WIDGETS_WIDTH, 150.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LIST_WIDGETS_HEIGHT, 80.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ICON_DEFAULT_OFFSET_SM, 20.);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,8 +68,7 @@ class StyleManager {
|
||||
* @return float
|
||||
*/
|
||||
public function getDefaultIconOffsetSM() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_ICON_DEFAULT_OFFSET_SM);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ICON_DEFAULT_OFFSET_SM);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,8 +77,7 @@ class StyleManager {
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultLabelStyle() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_LABEL_DEFAULT_STYLE);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LABEL_DEFAULT_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,8 +86,7 @@ class StyleManager {
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultQuadStyle() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_QUAD_DEFAULT_STYLE);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_QUAD_DEFAULT_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,8 +95,7 @@ class StyleManager {
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultQuadSubstyle() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,11 +109,7 @@ class StyleManager {
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = new Label();
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)
|
||||
->setPosition($width * -0.5 + 10, $height * -0.5 + 5)
|
||||
->setSize($width * 0.7, 4)
|
||||
->setTextSize(2)
|
||||
->setVisible(false);
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)->setPosition($width * -0.5 + 10, $height * -0.5 + 5)->setSize($width * 0.7, 4)->setTextSize(2)->setVisible(false);
|
||||
|
||||
return $descriptionLabel;
|
||||
}
|
||||
@@ -136,8 +120,7 @@ class StyleManager {
|
||||
* @return float
|
||||
*/
|
||||
public function getListWidgetsWidth() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_LIST_WIDGETS_WIDTH);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LIST_WIDGETS_WIDTH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,8 +129,7 @@ class StyleManager {
|
||||
* @return float
|
||||
*/
|
||||
public function getListWidgetsHeight() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_LIST_WIDGETS_HEIGHT);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LIST_WIDGETS_HEIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,49 +159,34 @@ class StyleManager {
|
||||
|
||||
// mainframe
|
||||
$frame = new Frame();
|
||||
$frame->setSize($width, $height)
|
||||
->setZ(35); //TODO place before scoreboards
|
||||
$frame->setSize($width, $height)->setZ(35); //TODO place before scoreboards
|
||||
|
||||
// Background Quad
|
||||
$backgroundQuad = new Quad();
|
||||
$frame->add($backgroundQuad);
|
||||
$backgroundQuad->setZ(-2)
|
||||
->setSize($width, $height)
|
||||
->setStyles($quadStyle, $quadSubstyle);
|
||||
$backgroundQuad->setZ(-2)->setSize($width, $height)->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
// Add Close Quad (X)
|
||||
$closeQuad = new Quad_Icons64x64_1();
|
||||
$frame->add($closeQuad);
|
||||
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3)
|
||||
->setSize(6, 6)
|
||||
->setSubStyle($closeQuad::SUBSTYLE_QuitRace)
|
||||
->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3)->setSize(6, 6)->setSubStyle($closeQuad::SUBSTYLE_QuitRace)->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||
|
||||
if ($script) {
|
||||
$pagerSize = 6.;
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->add($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2)
|
||||
->setSize($pagerSize, $pagerSize)
|
||||
->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->add($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)
|
||||
->setSize($pagerSize, $pagerSize)
|
||||
->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->add($pageCountLabel);
|
||||
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)
|
||||
->setPosition($width * 0.40, $height * -0.44, 1)
|
||||
->setStyle($pageCountLabel::STYLE_TextTitle1)
|
||||
->setTextSize(1.3);
|
||||
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.40, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(1.3);
|
||||
|
||||
if ($paging) {
|
||||
$paging->addButton($pagerNext)
|
||||
->addButton($pagerPrev)
|
||||
->setLabel($pageCountLabel);
|
||||
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,8 +199,7 @@ class StyleManager {
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultMainWindowStyle() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +208,6 @@ class StyleManager {
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultMainWindowSubStyle() {
|
||||
return $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE);
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,20 +56,13 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// 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');
|
||||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,9 +95,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$oldFolderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
$isInMapsFolder = false;
|
||||
if (!$oldFolderPath) {
|
||||
$oldFolderPath = $this->maniaControl->getServer()
|
||||
->getDirectory()
|
||||
->getMapsFolder();
|
||||
$oldFolderPath = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
|
||||
$isInMapsFolder = true;
|
||||
}
|
||||
$folderPath = $oldFolderPath;
|
||||
@@ -115,16 +106,12 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$folderName = basename($newFolderPath);
|
||||
switch ($folderName) {
|
||||
case 'Maps':
|
||||
$mapsDir = dirname($this->maniaControl->getServer()
|
||||
->getDirectory()
|
||||
->getMapsFolder());
|
||||
$mapsDir = dirname($this->maniaControl->getServer()->getDirectory()->getMapsFolder());
|
||||
$folderDir = dirname($folderPath);
|
||||
$isInMapsFolder = ($mapsDir === $folderDir);
|
||||
break;
|
||||
case 'UserData':
|
||||
$dataDir = dirname($this->maniaControl->getServer()
|
||||
->getDirectory()
|
||||
->getGameDataFolder());
|
||||
$dataDir = dirname($this->maniaControl->getServer()->getDirectory()->getGameDataFolder());
|
||||
$folderDir = dirname($folderPath);
|
||||
if ($dataDir === $folderDir) {
|
||||
// Prevent navigation out of maps directory
|
||||
@@ -140,32 +127,22 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$script = $maniaLink->getScript();
|
||||
$paging = new Paging();
|
||||
$script->addFeature($paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$index = 0;
|
||||
$posY = $height / 2 - 10;
|
||||
$pageFrame = null;
|
||||
|
||||
$navigateRootQuad = new Quad_Icons64x64_1();
|
||||
$frame->add($navigateRootQuad);
|
||||
$navigateRootQuad->setPosition($width * -0.47, $height * 0.45)
|
||||
->setSize(4, 4)
|
||||
->setSubStyle($navigateRootQuad::SUBSTYLE_ToolRoot);
|
||||
$navigateRootQuad->setPosition($width * -0.47, $height * 0.45)->setSize(4, 4)->setSubStyle($navigateRootQuad::SUBSTYLE_ToolRoot);
|
||||
|
||||
$navigateUpQuad = new Quad_Icons64x64_1();
|
||||
$frame->add($navigateUpQuad);
|
||||
$navigateUpQuad->setPosition($width * -0.44, $height * 0.45)
|
||||
->setSize(4, 4)
|
||||
->setSubStyle($navigateUpQuad::SUBSTYLE_ToolUp);
|
||||
$navigateUpQuad->setPosition($width * -0.44, $height * 0.45)->setSize(4, 4)->setSubStyle($navigateUpQuad::SUBSTYLE_ToolUp);
|
||||
|
||||
if (!$isInMapsFolder) {
|
||||
$navigateRootQuad->setAction(self::ACTION_NAVIGATE_ROOT);
|
||||
@@ -174,23 +151,13 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
|
||||
$directoryLabel = new Label_Text();
|
||||
$frame->add($directoryLabel);
|
||||
$dataFolder = $this->maniaControl->getServer()
|
||||
->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)
|
||||
->setHAlign($directoryLabel::LEFT)
|
||||
->setText($directoryText)
|
||||
->setTextSize(2);
|
||||
$directoryLabel->setPosition($width * -0.41, $height * 0.45)->setSize($width * 0.85, 4)->setHAlign($directoryLabel::LEFT)->setText($directoryText)->setTextSize(2);
|
||||
|
||||
$tooltipLabel = new Label();
|
||||
$frame->add($tooltipLabel);
|
||||
$tooltipLabel->setPosition($width * -0.48, $height * -0.44)
|
||||
->setSize($width * 0.8, 5)
|
||||
->setHAlign($tooltipLabel::LEFT)
|
||||
->setTextSize(1)
|
||||
->setText('tooltip');
|
||||
$tooltipLabel->setPosition($width * -0.48, $height * -0.44)->setSize($width * 0.8, 5)->setHAlign($tooltipLabel::LEFT)->setTextSize(1)->setText('tooltip');
|
||||
|
||||
$mapFiles = $this->scanMapFiles($folderPath);
|
||||
|
||||
@@ -198,15 +165,10 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
if (empty($mapFiles)) {
|
||||
$emptyLabel = new Label();
|
||||
$frame->add($emptyLabel);
|
||||
$emptyLabel->setY(20)
|
||||
->setTextColor('aaa')
|
||||
->setText('No files found.')
|
||||
->setTranslate(true);
|
||||
$emptyLabel->setY(20)->setTextColor('aaa')->setText('No files found.')->setTranslate(true);
|
||||
} else {
|
||||
$canAddMaps = $this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP);
|
||||
$canEraseMaps = $this->maniaControl->getAuthenticationManager()
|
||||
->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));
|
||||
@@ -228,50 +190,33 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
// Striped background line
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$mapFrame->add($lineQuad);
|
||||
$lineQuad->setZ(-1)
|
||||
->setSize($width, 4)
|
||||
->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||
$lineQuad->setZ(-1)->setSize($width, 4)->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||
}
|
||||
|
||||
// File name Label
|
||||
$nameLabel = new Label_Text();
|
||||
$mapFrame->add($nameLabel);
|
||||
$nameLabel->setX($width * -0.48)
|
||||
->setSize($width * 0.79, 4)
|
||||
->setHAlign($nameLabel::LEFT)
|
||||
->setStyle($nameLabel::STYLE_TextCardRaceRank)
|
||||
->setTextSize(1)
|
||||
->setText($fileName);
|
||||
$nameLabel->setX($width * -0.48)->setSize($width * 0.79, 4)->setHAlign($nameLabel::LEFT)->setStyle($nameLabel::STYLE_TextCardRaceRank)->setTextSize(1)->setText($fileName);
|
||||
|
||||
if (is_dir($filePath)) {
|
||||
// Folder
|
||||
$nameLabel->setAction(self::ACTION_OPEN_FOLDER . substr($shortFilePath, 0, -1))
|
||||
->addTooltipLabelFeature($tooltipLabel, 'Open folder ' . $fileName);
|
||||
$nameLabel->setAction(self::ACTION_OPEN_FOLDER . substr($shortFilePath, 0, -1))->addTooltipLabelFeature($tooltipLabel, 'Open folder ' . $fileName);
|
||||
} else {
|
||||
// File
|
||||
$nameLabel->setAction(self::ACTION_INSPECT_FILE . $fileName)
|
||||
->addTooltipLabelFeature($tooltipLabel, 'Inspect file ' . $fileName);
|
||||
$nameLabel->setAction(self::ACTION_INSPECT_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Inspect file ' . $fileName);
|
||||
|
||||
if ($canAddMaps) {
|
||||
// 'Add' button
|
||||
$addButton = new Quad_UIConstructionBullet_Buttons();
|
||||
$mapFrame->add($addButton);
|
||||
$addButton->setX($width * 0.42)
|
||||
->setSize(4, 4)
|
||||
->setSubStyle($addButton::SUBSTYLE_NewBullet)
|
||||
->setAction(self::ACTION_ADD_FILE . $fileName)
|
||||
->addTooltipLabelFeature($tooltipLabel, 'Add map ' . $fileName);
|
||||
$addButton->setX($width * 0.42)->setSize(4, 4)->setSubStyle($addButton::SUBSTYLE_NewBullet)->setAction(self::ACTION_ADD_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Add map ' . $fileName);
|
||||
}
|
||||
|
||||
if ($canEraseMaps) {
|
||||
// 'Erase' button
|
||||
$eraseButton = new Quad_UIConstruction_Buttons();
|
||||
$mapFrame->add($eraseButton);
|
||||
$eraseButton->setX($width * 0.46)
|
||||
->setSize(4, 4)
|
||||
->setSubStyle($eraseButton::SUBSTYLE_Erase)
|
||||
->setAction(self::ACTION_ERASE_FILE . $fileName)
|
||||
->addTooltipLabelFeature($tooltipLabel, 'Erase file ' . $fileName);
|
||||
$eraseButton->setX($width * 0.46)->setSize(4, 4)->setSubStyle($eraseButton::SUBSTYLE_Erase)->setAction(self::ACTION_ERASE_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Erase file ' . $fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,14 +227,10 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
} else {
|
||||
$errorLabel = new Label();
|
||||
$frame->add($errorLabel);
|
||||
$errorLabel->setY(20)
|
||||
->setTextColor('f30')
|
||||
->setText('No access to the directory.')
|
||||
->setTranslate(true);
|
||||
$errorLabel->setY(20)->setTextColor('f30')->setText('No access to the directory.')->setTranslate(true);
|
||||
}
|
||||
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, self::WIDGET_NAME);
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::WIDGET_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,52 +335,40 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
$filePath = $folderPath . $fileName;
|
||||
|
||||
$mapsFolder = $this->maniaControl->getServer()
|
||||
->getDirectory()
|
||||
->getMapsFolder();
|
||||
$mapsFolder = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
|
||||
$relativeFilePath = substr($filePath, strlen($mapsFolder));
|
||||
|
||||
// Check for valid map
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->checkMapForCurrentServerParams($relativeFilePath);
|
||||
$this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeFilePath);
|
||||
} catch (InvalidMapException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $player);
|
||||
$this->maniaControl->getChat()->sendException($exception, $player);
|
||||
return;
|
||||
} catch (FileException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $player);
|
||||
$this->maniaControl->getChat()->sendException($exception, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add map to map list
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->insertMap($relativeFilePath);
|
||||
$this->maniaControl->getClient()->insertMap($relativeFilePath);
|
||||
} catch (AlreadyInListException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $player);
|
||||
$this->maniaControl->getChat()->sendException($exception, $player);
|
||||
return;
|
||||
}
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->fetchMapByFileName($relativeFilePath);
|
||||
$map = $this->maniaControl->getMapManager()->fetchMapByFileName($relativeFilePath);
|
||||
if (!$map) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Message
|
||||
$message = $player->getEscapedNickname() . ' added ' . $map->getEscapedName() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
|
||||
// Queue requested Map
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->addMapToMapQueue($player, $map);
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($player, $map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,12 +383,10 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
$filePath = $folderPath . $fileName;
|
||||
if (@unlink($filePath)) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess("Erased {$fileName}!");
|
||||
$this->maniaControl->getChat()->sendSuccess("Erased {$fileName}!");
|
||||
$this->showManiaLink($player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Couldn't erase {$fileName}!");
|
||||
$this->maniaControl->getChat()->sendError("Couldn't erase {$fileName}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,19 +33,14 @@ class MapActions {
|
||||
*/
|
||||
public function skipMap() {
|
||||
// Force an EndMap on the MapQueue to set the next Map
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->endMap(null);
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->endMap(null);
|
||||
|
||||
// Ignore EndMap on MapQueue
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->dontQueueNextMapChange();
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||
|
||||
// Switch The Map
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->nextMap();
|
||||
$this->maniaControl->getClient()->nextMap();
|
||||
} catch (ChangeInProgressException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,44 +50,27 @@ 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');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,36 +79,28 @@ 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');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,24 +110,18 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,25 +132,20 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,25 +155,20 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,17 +178,14 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Shuffles the maps
|
||||
$this->maniaControl->getMapManager()
|
||||
->shuffleMapList($player);
|
||||
$this->maniaControl->getMapManager()->shuffleMapList($player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,23 +195,19 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,21 +217,16 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -290,21 +237,17 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$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) {
|
||||
}
|
||||
}
|
||||
@@ -317,22 +260,16 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,11 +279,9 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -363,16 +298,13 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,11 +315,9 @@ 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)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -404,18 +334,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,14 +354,11 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -447,8 +370,7 @@ 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) {
|
||||
@@ -458,14 +380,11 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,9 +395,7 @@ 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]);
|
||||
@@ -499,20 +416,15 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,16 +436,13 @@ 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.);
|
||||
@@ -565,12 +474,9 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,8 +487,7 @@ 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);
|
||||
@@ -591,9 +496,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$maps = array_reverse($maps);
|
||||
}
|
||||
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player, $maps);
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $maps);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,8 +506,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,25 +73,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// 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->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->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_CHECK_UPDATE, $this, 'checkUpdates');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->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');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,9 +93,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
public function clearMapQueue(array $chatCallback, Player $player) {
|
||||
// Clears the Map Queue
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->clearMapQueue($player);
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->clearMapQueue($player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,9 +104,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
public function checkUpdates(array $chatCallback, Player $player) {
|
||||
// Update Mx Infos
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMXManager()
|
||||
->fetchManiaExchangeMapInformation();
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation();
|
||||
|
||||
// Reshow the Maplist
|
||||
$this->showMapList($player);
|
||||
@@ -131,33 +118,25 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* @param int $pageIndex
|
||||
*/
|
||||
public function showMapList(Player $player, $mapList = null, $pageIndex = -1) {
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$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->getMapManager()
|
||||
->getMapQueue()
|
||||
->getQueueBuffer();
|
||||
$queueBuffer = $this->maniaControl->getMapManager()->getMapQueue()->getQueueBuffer();
|
||||
|
||||
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex);
|
||||
$mapsBeginIndex = $this->getChunkMapsBeginIndex($chunkIndex);
|
||||
|
||||
// Get Maps
|
||||
if (!is_array($mapList)) {
|
||||
$mapList = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
$mapList = $this->maniaControl->getMapManager()->getMaps();
|
||||
}
|
||||
$mapList = array_slice($mapList, $mapsBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE);
|
||||
|
||||
$totalMapsCount = $this->maniaControl->getMapManager()
|
||||
->getMapsCount();
|
||||
$totalMapsCount = $this->maniaControl->getMapManager()->getMapsCount();
|
||||
$pagesCount = ceil($totalMapsCount / self::MAX_MAPS_PER_PAGE);
|
||||
|
||||
// Create ManiaLink
|
||||
@@ -170,14 +149,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Admin Buttons
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->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();
|
||||
@@ -196,8 +172,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$quad->setAction(self::ACTION_CLEAR_MAPQUEUE);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)
|
||||
) {
|
||||
// Check Update
|
||||
$label = new Label_Button();
|
||||
@@ -218,19 +193,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxQuad = new Quad();
|
||||
$frame->add($mxQuad);
|
||||
$mxQuad->setSize(3, 3);
|
||||
$mxQuad->setImage($this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_GREEN));
|
||||
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_GREEN_MOVER));
|
||||
$mxQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN));
|
||||
$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->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
) {
|
||||
// Directory browser
|
||||
$browserButton = new Label_Button();
|
||||
@@ -253,21 +223,15 @@ 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->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
|
||||
// Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
$queuedMaps = $this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->getQueuedMapsRanking();
|
||||
$queuedMaps = $this->maniaControl->getMapManager()->getMapQueue()->getQueuedMapsRanking();
|
||||
/** @var KarmaPlugin $karmaPlugin */
|
||||
$karmaPlugin = $this->maniaControl->getPluginManager()
|
||||
->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);
|
||||
@@ -277,20 +241,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$posY = $height / 2 - 10;
|
||||
$pageFrame = null;
|
||||
|
||||
$currentMap = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
$mxIcon = $this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON);
|
||||
$mxIconHover = $this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_MOVER);
|
||||
$mxIconGreen = $this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_GREEN);
|
||||
$mxIconGreenHover = $this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_GREEN_MOVER);
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$mxIcon = $this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON);
|
||||
$mxIconHover = $this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER);
|
||||
$mxIconGreen = $this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN);
|
||||
$mxIconGreenHover = $this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN_MOVER);
|
||||
|
||||
foreach ($mapList as $map) {
|
||||
/** @var Map $map */
|
||||
@@ -353,8 +308,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
// Update Button
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->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);
|
||||
}
|
||||
@@ -363,8 +317,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->getManialinkManager()
|
||||
->labelLine($mapFrame, $array);
|
||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
|
||||
if (isset($labels[3])) {
|
||||
/** @var Label $label */
|
||||
$label = $labels[3];
|
||||
@@ -386,9 +339,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$label->setTextColor('fff');
|
||||
|
||||
// Checks if the Player who opened the Widget has queued the map
|
||||
$queuer = $this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->getQueuer($map->uid);
|
||||
$queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($map->uid);
|
||||
if ($queuer->login == $player->login) {
|
||||
$description = 'Remove ' . $map->getEscapedName() . ' from the Map Queue';
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@@ -407,8 +358,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$queueLabel->setText('+');
|
||||
|
||||
if (in_array($map->uid, $queueBuffer)) {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->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);
|
||||
}
|
||||
@@ -423,8 +373,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->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();
|
||||
@@ -442,8 +391,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$removeButton->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->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();
|
||||
@@ -461,11 +409,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$description = 'Switch Directly to Map: ' . $map->getEscapedName();
|
||||
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
if ($this->maniaControl->getPluginManager()
|
||||
->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
) {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
) {
|
||||
// Switch Map Voting for Admins
|
||||
$switchQuad = new Quad_UIConstruction_Buttons();
|
||||
@@ -498,8 +444,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$karma = $karmaPlugin->getMapKarma($map);
|
||||
$votes = $karmaPlugin->getMapVotes($map);
|
||||
if (is_numeric($karma)) {
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)
|
||||
) {
|
||||
$karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';
|
||||
} else {
|
||||
@@ -547,8 +492,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$index++;
|
||||
}
|
||||
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, self::WIDGET_NAME);
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::WIDGET_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,8 +502,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkIndexFromPageNumber($pageIndex) {
|
||||
$mapsCount = $this->maniaControl->getMapManager()
|
||||
->getMapsCount();
|
||||
$mapsCount = $this->maniaControl->getMapManager()->getMapsCount();
|
||||
$pagesCount = ceil($mapsCount / self::MAX_MAPS_PER_PAGE);
|
||||
if ($pageIndex > $pagesCount - 1) {
|
||||
$pageIndex = $pagesCount - 1;
|
||||
@@ -590,15 +533,9 @@ 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->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
$confirmFrame = new Frame();
|
||||
$maniaLink->add($confirmFrame);
|
||||
@@ -678,77 +615,60 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$mapUid = $actionArray[2];
|
||||
|
||||
switch ($action) {
|
||||
case self::ACTION_UPDATE_MAP:
|
||||
$this->maniaControl->getMapManager()
|
||||
->updateMap($player, $mapUid);
|
||||
$this->maniaControl->getMapManager()->updateMap($player, $mapUid);
|
||||
$this->showMapList($player);
|
||||
break;
|
||||
case self::ACTION_REMOVE_MAP:
|
||||
try {
|
||||
$this->maniaControl->getMapManager()
|
||||
->removeMap($player, $mapUid);
|
||||
$this->maniaControl->getMapManager()->removeMap($player, $mapUid);
|
||||
} catch (FileException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($e, $player);
|
||||
$this->maniaControl->getChat()->sendException($e, $player);
|
||||
}
|
||||
break;
|
||||
case self::ACTION_SWITCH_MAP:
|
||||
// Don't queue on Map-Change
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->dontQueueNextMapChange();
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->jumpToMapIdent($mapUid);
|
||||
$this->maniaControl->getClient()->jumpToMapIdent($mapUid);
|
||||
} catch (NextMapException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->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->getChat()
|
||||
->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->getMapManager()
|
||||
->getMapByUid($mapUid);
|
||||
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
|
||||
|
||||
$message = $player->getEscapedNickname() . ' skipped to Map $z' . $map->getEscapedName() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
|
||||
$this->playerCloseWidget($player);
|
||||
break;
|
||||
case self::ACTION_START_SWITCH_VOTE:
|
||||
/** @var CustomVotesPlugin $votesPlugin */
|
||||
$votesPlugin = $this->maniaControl->getPluginManager()
|
||||
->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->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)
|
||||
->setStopCallback(Callbacks::ENDMAP);
|
||||
$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->getMapManager()
|
||||
->getMapQueue()
|
||||
->dontQueueNextMapChange();
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->JumpToMapIdent($map->uid);
|
||||
$this->maniaControl->getClient()->JumpToMapIdent($map->uid);
|
||||
} catch (NextMapException $exception) {
|
||||
return;
|
||||
} catch (NotInListException $exception) {
|
||||
@@ -758,20 +678,15 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation('$sVote Successful -> Map switched!');
|
||||
$this->maniaControl->getChat()->sendInformation('$sVote Successful -> Map switched!');
|
||||
});
|
||||
break;
|
||||
case self::ACTION_QUEUED_MAP:
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->addMapToMapQueue($callback[1][1], $mapUid);
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($callback[1][1], $mapUid);
|
||||
$this->showMapList($player);
|
||||
break;
|
||||
case self::ACTION_UNQUEUE_MAP:
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->removeFromMapQueue($player, $mapUid);
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->removeFromMapQueue($player, $mapUid);
|
||||
$this->showMapList($player);
|
||||
break;
|
||||
default:
|
||||
@@ -791,16 +706,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
public function playerCloseWidget(Player $player) {
|
||||
$player->destroyCache($this, self::CACHE_CURRENT_PAGE);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->closeWidget($player);
|
||||
$this->maniaControl->getManialinkManager()->closeWidget($player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reopen the widget on Map Begin, MapListChanged, etc.
|
||||
*/
|
||||
public function updateWidget() {
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
foreach ($players as $player) {
|
||||
$currentPage = $player->getCache($this, self::CACHE_CURRENT_PAGE);
|
||||
if ($currentPage !== null) {
|
||||
|
||||
@@ -104,36 +104,23 @@ class MapManager implements CallbackListener {
|
||||
$this->mapActions = new MapActions($maniaControl);
|
||||
|
||||
// Callbacks
|
||||
$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');
|
||||
$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->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);
|
||||
$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->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);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,8 +129,7 @@ class MapManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_MAPS . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`mxid` int(11),
|
||||
@@ -238,8 +224,7 @@ class MapManager implements CallbackListener {
|
||||
$this->updateMapTimestamp($uid);
|
||||
|
||||
if (!isset($uid) || !isset($this->maps[$uid])) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Error updating Map: Unknown UID '{$uid}'!", $admin);
|
||||
$this->maniaControl->getChat()->sendError("Error updating Map: Unknown UID '{$uid}'!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,8 +243,7 @@ class MapManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function updateMapTimestamp($uid) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
|
||||
mxid = 0,
|
||||
changed = NOW()
|
||||
@@ -290,8 +274,7 @@ class MapManager implements CallbackListener {
|
||||
*/
|
||||
public function removeMap(Player $admin, $uid, $eraseFile = false, $message = true) {
|
||||
if (!isset($this->maps[$uid])) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Map does not exist!', $admin);
|
||||
$this->maniaControl->getChat()->sendError('Map does not exist!', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -299,18 +282,15 @@ class MapManager implements CallbackListener {
|
||||
$map = $this->maps[$uid];
|
||||
|
||||
// Unset the Map everywhere
|
||||
$this->getMapQueue()
|
||||
->removeFromMapQueue($admin, $map->uid);
|
||||
$this->getMapQueue()->removeFromMapQueue($admin, $map->uid);
|
||||
|
||||
if ($map->mx) {
|
||||
$this->getMXManager()
|
||||
->unsetMap($map->mx->id);
|
||||
$this->getMXManager()->unsetMap($map->mx->id);
|
||||
}
|
||||
|
||||
// Remove map
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->removeMap($map->fileName);
|
||||
$this->maniaControl->getClient()->removeMap($map->fileName);
|
||||
} catch (NotInListException $e) {
|
||||
}
|
||||
|
||||
@@ -318,20 +298,16 @@ class MapManager implements CallbackListener {
|
||||
|
||||
if ($eraseFile) {
|
||||
// Check if ManiaControl can even write to the maps dir
|
||||
$mapDir = $this->maniaControl->getClient()
|
||||
->getMapsDirectory();
|
||||
if ($this->maniaControl->getServer()
|
||||
->checkAccess($mapDir)
|
||||
$mapDir = $this->maniaControl->getClient()->getMapsDirectory();
|
||||
if ($this->maniaControl->getServer()->checkAccess($mapDir)
|
||||
) {
|
||||
// Delete map file
|
||||
if (!@unlink($mapDir . $map->fileName)) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Couldn't erase the map file.", $admin);
|
||||
$this->maniaControl->getChat()->sendError("Couldn't erase the map file.", $admin);
|
||||
$eraseFile = false;
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->getChat()
|
||||
->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;
|
||||
}
|
||||
}
|
||||
@@ -340,8 +316,7 @@ class MapManager implements CallbackListener {
|
||||
if ($message) {
|
||||
$action = ($eraseFile ? 'erased' : 'removed');
|
||||
$message = $admin->getEscapedNickname() . ' ' . $action . ' ' . $map->getEscapedName() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
}
|
||||
}
|
||||
@@ -356,27 +331,22 @@ class MapManager implements CallbackListener {
|
||||
public function addMapFromMx($mapId, $login, $update = false) {
|
||||
if (is_numeric($mapId)) {
|
||||
// Check if map exists
|
||||
$this->maniaControl->getMapManager()
|
||||
->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->getChat()
|
||||
->sendError('Invalid MX-Id!', $login);
|
||||
$this->maniaControl->getChat()->sendError('Invalid MX-Id!', $login);
|
||||
return;
|
||||
}
|
||||
|
||||
// Download the file
|
||||
$this->maniaControl->getFileReader()
|
||||
->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->getChat()
|
||||
->sendError("Download failed: '{$error}'!", $login);
|
||||
$this->maniaControl->getChat()->sendError("Download failed: '{$error}'!", $login);
|
||||
return;
|
||||
}
|
||||
$this->processMapFile($file, $mapInfo, $login, $update);
|
||||
@@ -397,8 +367,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->getChat()
|
||||
->sendError('Map is already on the server!', $login);
|
||||
$this->maniaControl->getChat()->sendError('Map is already on the server!', $login);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -406,41 +375,33 @@ class MapManager implements CallbackListener {
|
||||
$fileName = $mapInfo->id . '_' . $mapInfo->name . '.Map.Gbx';
|
||||
$fileName = FileUtil::getClearedFileName($fileName);
|
||||
|
||||
$downloadFolderName = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, 'MapDownloadDirectory', 'MX');
|
||||
$downloadFolderName = $this->maniaControl->getSettingManager()->getSettingValue($this, 'MapDownloadDirectory', 'MX');
|
||||
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
|
||||
$mapDir = $this->maniaControl->getServer()
|
||||
->getDirectory()
|
||||
->getMapsFolder();
|
||||
$mapDir = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
|
||||
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
|
||||
$fullMapFileName = $downloadDirectory . $fileName;
|
||||
|
||||
// Check if it can get written locally
|
||||
if ($this->maniaControl->getServer()
|
||||
->checkAccess($mapDir)
|
||||
if ($this->maniaControl->getServer()->checkAccess($mapDir)
|
||||
) {
|
||||
// Create download directory if necessary
|
||||
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.", $login);
|
||||
$this->maniaControl->getChat()->sendError("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.", $login);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file_put_contents($fullMapFileName, $file)) {
|
||||
// Save error
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Saving map failed!', $login);
|
||||
$this->maniaControl->getChat()->sendError('Saving map failed!', $login);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Write map via write file method
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->writeFile($relativeMapFileName, $file);
|
||||
$this->maniaControl->getClient()->writeFile($relativeMapFileName, $file);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
if ($e->getMessage() === 'data are too big') {
|
||||
$this->maniaControl->getChat()
|
||||
->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;
|
||||
@@ -449,63 +410,49 @@ class MapManager implements CallbackListener {
|
||||
|
||||
// Check for valid map
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->checkMapForCurrentServerParams($relativeMapFileName);
|
||||
$this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeMapFileName);
|
||||
} catch (InvalidMapException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $login);
|
||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
||||
return;
|
||||
} catch (FileException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $login);
|
||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add map to map list
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->insertMap($relativeMapFileName);
|
||||
$this->maniaControl->getClient()->insertMap($relativeMapFileName);
|
||||
} catch (AlreadyInListException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $login);
|
||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
||||
return;
|
||||
}
|
||||
$this->updateFullMapList();
|
||||
|
||||
// Update Mx MapInfo
|
||||
$this->maniaControl->getMapManager()
|
||||
->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->getErrorHandler()
|
||||
->triggerDebugNotice('Map not in List after Insert!');
|
||||
$this->maniaControl->getChat()
|
||||
->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->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
if (!$update) {
|
||||
// Message
|
||||
$message = $player->getEscapedNickname() . ' added $<' . $mapInfo->name . '$>!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
// Queue requested Map
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapQueue()
|
||||
->addMapToMapQueue($login, $mapInfo->uid);
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid);
|
||||
} else {
|
||||
$message = $player->getEscapedNickname() . ' updated $<' . $mapInfo->name . '$>!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
}
|
||||
}
|
||||
@@ -532,8 +479,7 @@ class MapManager implements CallbackListener {
|
||||
try {
|
||||
$offset = 0;
|
||||
while ($this->maniaControl->getClient()) {
|
||||
$maps = $this->maniaControl->getClient()
|
||||
->getMapList(150, $offset);
|
||||
$maps = $this->maniaControl->getClient()->getMapList(150, $offset);
|
||||
|
||||
foreach ($maps as $rpcMap) {
|
||||
if (array_key_exists($rpcMap->uId, $this->maps)) {
|
||||
@@ -555,26 +501,21 @@ class MapManager implements CallbackListener {
|
||||
$this->maps = $tempList;
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_MAPS_UPDATED);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPS_UPDATED);
|
||||
|
||||
// Write MapList
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_AUTOSAVE_MAPLIST)
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_AUTOSAVE_MAPLIST)
|
||||
) {
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WRITE_OWN_MAPLIST_FILE)
|
||||
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->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MAPLIST_FILE);
|
||||
$matchSettingsFileName = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIST_FILE);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->saveMatchSettings($matchSettingsFileName);
|
||||
$this->maniaControl->getClient()->saveMatchSettings($matchSettingsFileName);
|
||||
} catch (FileException $e) {
|
||||
Logger::logError("Unable to write the playlist file, please checkout your MX-Folders File permissions!");
|
||||
}
|
||||
@@ -601,8 +542,7 @@ class MapManager implements CallbackListener {
|
||||
*/
|
||||
private function saveMap(Map &$map) {
|
||||
//TODO saveMaps for whole maplist at once (usage of prepared statements)
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mapQuery = "INSERT INTO `" . self::TABLE_MAPS . "` (
|
||||
`uid`,
|
||||
`name`,
|
||||
@@ -653,12 +593,10 @@ class MapManager implements CallbackListener {
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->chooseNextMapList($mapArray);
|
||||
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
|
||||
} catch (Exception $e) {
|
||||
//TODO temp added 19.04.2014
|
||||
$this->maniaControl->getErrorHandler()
|
||||
->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;
|
||||
}
|
||||
@@ -667,8 +605,7 @@ class MapManager implements CallbackListener {
|
||||
|
||||
if ($admin) {
|
||||
$message = $admin->getEscapedNickname() . ' shuffled the Maplist!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
}
|
||||
|
||||
@@ -684,8 +621,7 @@ class MapManager implements CallbackListener {
|
||||
*/
|
||||
private function fetchCurrentMap() {
|
||||
try {
|
||||
$rpcMap = $this->maniaControl->getClient()
|
||||
->getCurrentMapInfo();
|
||||
$rpcMap = $this->maniaControl->getClient()->getCurrentMapInfo();
|
||||
} catch (UnavailableFeatureException $exception) {
|
||||
return null;
|
||||
}
|
||||
@@ -730,8 +666,7 @@ class MapManager implements CallbackListener {
|
||||
array_shift($mapArray);
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->chooseNextMapList($mapArray);
|
||||
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
|
||||
} catch (Exception $e) {
|
||||
trigger_error("Error restructuring the Maplist. " . $e->getMessage());
|
||||
return false;
|
||||
@@ -795,8 +730,7 @@ class MapManager implements CallbackListener {
|
||||
*/
|
||||
public function handleAfterInit() {
|
||||
// Fetch MX infos
|
||||
$this->getMXManager()
|
||||
->fetchManiaExchangeMapInformation();
|
||||
$this->getMXManager()->fetchManiaExchangeMapInformation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -831,8 +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->getClient()
|
||||
->getCurrentMapInfo();
|
||||
$rpcMap = $this->maniaControl->getClient()->getCurrentMapInfo();
|
||||
$this->currentMap->nbLaps = $rpcMap->nbLaps;
|
||||
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
|
||||
}
|
||||
@@ -842,12 +775,10 @@ class MapManager implements CallbackListener {
|
||||
$this->restructureMapList();
|
||||
|
||||
// Update the mx of the map (for update checks, etc.)
|
||||
$this->getMXManager()
|
||||
->fetchManiaExchangeMapInformation($this->currentMap);
|
||||
$this->getMXManager()->fetchManiaExchangeMapInformation($this->currentMap);
|
||||
|
||||
// Trigger own BeginMap callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -861,8 +792,7 @@ class MapManager implements CallbackListener {
|
||||
$this->mapBegan = false;
|
||||
|
||||
// Trigger own EndMap callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -872,8 +802,7 @@ class MapManager implements CallbackListener {
|
||||
* @return Map
|
||||
*/
|
||||
public function fetchMapByFileName($relativeFileName) {
|
||||
$mapInfo = $this->maniaControl->getClient()
|
||||
->getMapInfo($relativeFileName);
|
||||
$mapInfo = $this->maniaControl->getClient()->getMapInfo($relativeFileName);
|
||||
if (!$mapInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -56,38 +56,25 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// 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');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'endMap');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'beginMap');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
|
||||
// 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->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);
|
||||
|
||||
// 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);
|
||||
$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);
|
||||
|
||||
// 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.');
|
||||
$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.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,8 +88,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
* Add current map to buffer on startup
|
||||
*/
|
||||
public function handleAfterInit() {
|
||||
$currentMap = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$this->buffer[] = $currentMap->uid;
|
||||
}
|
||||
|
||||
@@ -122,34 +108,28 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
* @param Player $admin
|
||||
*/
|
||||
public function clearMapQueue(Player $admin) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->queuedMaps)) {
|
||||
$this->maniaControl->getChat()
|
||||
->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->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
|
||||
//Destroy map - queue list
|
||||
$this->queuedMaps = array();
|
||||
|
||||
$message = '$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Map-Queue!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($message);
|
||||
$this->maniaControl->getChat()->sendInformation($message);
|
||||
Logger::logInfo($message, true);
|
||||
|
||||
// Trigger callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear'));
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,8 +169,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
*/
|
||||
public function showMapQueue(Player $player) {
|
||||
if (empty($this->queuedMaps)) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
||||
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,8 +180,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$index++;
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($message, $player);
|
||||
$this->maniaControl->getChat()->sendInformation($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,8 +190,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
*/
|
||||
public function showMapQueueManialink(Player $player) {
|
||||
if (empty($this->queuedMaps)) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('There are no Maps in the Jukebox!', $player);
|
||||
$this->maniaControl->getChat()->sendError('There are no Maps in the Jukebox!', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,9 +199,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
array_push($maps, $queuedMap[1]);
|
||||
}
|
||||
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMapList()
|
||||
->showMapList($player, $maps);
|
||||
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $maps);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,15 +234,13 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
* @param string $uid
|
||||
*/
|
||||
public function addMapToMapQueue($login, $uid) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if player is allowed to add (another) map
|
||||
$isModerator = $this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$isModerator = $this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
$mapsForPlayer = 0;
|
||||
foreach ($this->queuedMaps as $queuedMap) {
|
||||
@@ -277,19 +250,15 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
if ($isModerator) {
|
||||
$maxAdmin = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
||||
$maxAdmin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
||||
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
|
||||
$this->maniaControl->getChat()
|
||||
->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->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
||||
$maxPlayer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
||||
if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) {
|
||||
$this->maniaControl->getChat()
|
||||
->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;
|
||||
}
|
||||
}
|
||||
@@ -301,36 +270,30 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$uid = $map->uid;
|
||||
}
|
||||
if (array_key_exists($uid, $this->queuedMaps)) {
|
||||
$this->maniaControl->getChat()
|
||||
->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->getChat()
|
||||
->sendError('That map has recently been played!', $login);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->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->getMapManager()
|
||||
->getMapByUid($uid);
|
||||
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
|
||||
}
|
||||
|
||||
$this->queuedMaps[$uid] = array($player, $map);
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->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->getCallbackManager()
|
||||
->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,12 +310,10 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$map = $this->queuedMaps[$uid][1];
|
||||
unset($this->queuedMaps[$uid]);
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->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->getCallbackManager()
|
||||
->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('remove', $map));
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('remove', $map));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,8 +329,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
$this->nextMap = null;
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->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) {
|
||||
@@ -381,14 +341,12 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
// Player found, so play this map
|
||||
if ($this->maniaControl->getPlayerManager()
|
||||
->getPlayer($player->login)
|
||||
if ($this->maniaControl->getPlayerManager()->getPlayer($player->login)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->getSettingManager()
|
||||
->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) {
|
||||
@@ -397,14 +355,12 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
// Trigger callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->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->getChat()
|
||||
->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!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,12 +372,10 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
$map = $this->nextMap[1];
|
||||
/** @var Map $map */
|
||||
$this->maniaControl->getChat()
|
||||
->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->getClient()
|
||||
->setNextMapIdent($map->uid);
|
||||
$this->maniaControl->getClient()->setNextMapIdent($map->uid);
|
||||
} catch (NextMapException $e) {
|
||||
} catch (NotInListException $e) {
|
||||
}
|
||||
@@ -437,8 +391,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (count($this->buffer) >= $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_BUFFERSIZE)
|
||||
if (count($this->buffer) >= $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_BUFFERSIZE)
|
||||
) {
|
||||
array_shift($this->buffer);
|
||||
}
|
||||
|
||||
@@ -313,9 +313,7 @@ class Player {
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPlayerData($object, $dataName, $serverIndex = -1) {
|
||||
return $this->maniaControl->getPlayerManager()
|
||||
->getPlayerDataManager()
|
||||
->getPlayerData($object, $dataName, $this, $serverIndex);
|
||||
return $this->maniaControl->getPlayerManager()->getPlayerDataManager()->getPlayerData($object, $dataName, $this, $serverIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,9 +326,7 @@ class Player {
|
||||
* @return bool
|
||||
*/
|
||||
public function setPlayerData($object, $dataName, $value, $serverIndex = -1) {
|
||||
return $this->maniaControl->getPlayerManager()
|
||||
->getPlayerDataManager()
|
||||
->setPlayerData($object, $dataName, $this, $value, $serverIndex);
|
||||
return $this->maniaControl->getPlayerManager()->getPlayerDataManager()->setPlayerData($object, $dataName, $this, $value, $serverIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,20 +63,13 @@ class PlayerActions {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_BAN_PLAYER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_KICK_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_WARN_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_MUTE_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_PLAY, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_TEAM, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_SPEC, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_BAN_PLAYER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_KICK_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_WARN_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_MUTE_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_PLAY, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_TEAM, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_SPEC, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,17 +80,13 @@ class PlayerActions {
|
||||
* @param int $teamId
|
||||
*/
|
||||
public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target || !$admin) {
|
||||
return;
|
||||
}
|
||||
@@ -108,14 +97,12 @@ class PlayerActions {
|
||||
return;
|
||||
}
|
||||
} catch (FaultException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forcePlayerTeam($target->login, $teamId);
|
||||
$this->maniaControl->getClient()->forcePlayerTeam($target->login, $teamId);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->forcePlayerToPlay($adminLogin, $targetLogin);
|
||||
return;
|
||||
@@ -125,8 +112,7 @@ class PlayerActions {
|
||||
}
|
||||
|
||||
$chatMessage = false;
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
if ($teamId === self::TEAM_BLUE) {
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' into the Blue-Team!';
|
||||
} else if ($teamId === self::TEAM_RED) {
|
||||
@@ -135,8 +121,7 @@ class PlayerActions {
|
||||
if (!$chatMessage) {
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -150,37 +135,29 @@ class PlayerActions {
|
||||
* @return bool
|
||||
*/
|
||||
public function forcePlayerToPlay($adminLogin, $targetLogin, $userIsAbleToSelect = true, $displayAnnouncement = true) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return false;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($userIsAbleToSelect) {
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -188,8 +165,7 @@ class PlayerActions {
|
||||
// Announce force
|
||||
if ($displayAnnouncement) {
|
||||
$chatMessage = $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Play!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -205,43 +181,34 @@ class PlayerActions {
|
||||
*/
|
||||
public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE,
|
||||
$releaseSlot = true) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$admin || !$target || $target->isSpectator) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, $spectatorState);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, $spectatorState);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin->login);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Spectator!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
|
||||
if ($releaseSlot) {
|
||||
// Free player slot
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->spectatorReleasePlayerSlot($target->login);
|
||||
$this->maniaControl->getClient()->spectatorReleasePlayerSlot($target->login);
|
||||
} catch (PlayerStateException $e) {
|
||||
} catch (UnknownPlayerException $e) {
|
||||
}
|
||||
@@ -255,37 +222,29 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function unMutePlayer($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->unIgnore($targetLogin);
|
||||
$this->maniaControl->getClient()->unIgnore($targetLogin);
|
||||
} catch (NotInListException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Player is not ignored!');
|
||||
$this->maniaControl->getChat()->sendError('Player is not ignored!');
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' un-muted ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -296,37 +255,29 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function mutePlayer($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->ignore($targetLogin);
|
||||
$this->maniaControl->getClient()->ignore($targetLogin);
|
||||
} catch (AlreadyInListException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player already ignored!");
|
||||
$this->maniaControl->getChat()->sendError("Player already ignored!");
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' muted ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -337,18 +288,14 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function warnPlayer($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_WARN_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_WARN_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$target) {
|
||||
return;
|
||||
@@ -363,12 +310,8 @@ class PlayerActions {
|
||||
// Build Manialink
|
||||
$width = 80;
|
||||
$height = 50;
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$frame = new Frame();
|
||||
@@ -412,15 +355,12 @@ class PlayerActions {
|
||||
}
|
||||
|
||||
// Display manialink
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $target);
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target);
|
||||
|
||||
// Announce warning
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' warned ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::log($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -432,41 +372,32 @@ class PlayerActions {
|
||||
* @param string $message
|
||||
*/
|
||||
public function kickPlayer($adminLogin, $targetLogin, $message = '') {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_KICK_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_KICK_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ($target->isFakePlayer()) {
|
||||
$this->maniaControl->getClient()
|
||||
->disconnectFakePlayer($target->login);
|
||||
$this->maniaControl->getClient()->disconnectFakePlayer($target->login);
|
||||
} else {
|
||||
$this->maniaControl->getClient()
|
||||
->kick($target->login, $message);
|
||||
$this->maniaControl->getClient()->kick($target->login, $message);
|
||||
}
|
||||
} catch (UnknownPlayerException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($e, $admin);
|
||||
$this->maniaControl->getChat()->sendException($e, $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce kick
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' kicked ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -478,36 +409,28 @@ class PlayerActions {
|
||||
* @param string $message
|
||||
*/
|
||||
public function banPlayer($adminLogin, $targetLogin, $message = '') {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_BAN_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_BAN_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target->isFakePlayer()) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('It is not possible to Ban a bot', $admin);
|
||||
$this->maniaControl->getChat()->sendError('It is not possible to Ban a bot', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getClient()
|
||||
->ban($target->login, $message);
|
||||
$this->maniaControl->getClient()->ban($target->login, $message);
|
||||
|
||||
// Announce ban
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' banned ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -519,46 +442,35 @@ class PlayerActions {
|
||||
* @param int $authLevel
|
||||
*/
|
||||
public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$admin || !$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
$authLevelName = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($authLevel);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($admin, $authLevel + 1)
|
||||
$authLevelName = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($authLevel);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($admin, $authLevel + 1)
|
||||
) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("You don't have the permission to add a {$authLevelName}!", $admin);
|
||||
$this->maniaControl->getChat()->sendError("You don't have the permission to add a {$authLevelName}!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($target, $authLevel)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($target, $authLevel)
|
||||
) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("This Player is already {$authLevelName}!", $admin);
|
||||
$this->maniaControl->getChat()->sendError("This Player is already {$authLevelName}!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, $authLevel);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, $authLevel);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $admin);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce granting
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as $< ' . $authLevelName . '$>!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -569,46 +481,35 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function revokeAuthLevel($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$admin || !$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($admin, $target->authLevel + 1)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($admin, $target->authLevel + 1)
|
||||
) {
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($target->authLevel);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("You can't revoke the Rights of a {$title}!", $admin);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel);
|
||||
$this->maniaControl->getChat()->sendError("You can't revoke the Rights of a {$title}!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)
|
||||
) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("MasterAdmins can't be removed!", $admin);
|
||||
$this->maniaControl->getChat()->sendError("MasterAdmins can't be removed!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $admin);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce revoke
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' revoked the Rights of ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@@ -619,8 +520,7 @@ class PlayerActions {
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlayerMuted($login) {
|
||||
$ignoreList = $this->maniaControl->getClient()
|
||||
->getIgnoreList(100, 0);
|
||||
$ignoreList = $this->maniaControl->getClient()->getIgnoreList(100, 0);
|
||||
foreach ($ignoreList as $ignoredPlayers) {
|
||||
if ($ignoredPlayers->login === $login) {
|
||||
return true;
|
||||
|
||||
@@ -44,51 +44,34 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Admin commands
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('kick', $this, 'command_Kick', true, 'Kicks player from the server.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('ban', $this, 'command_Ban', true, 'Bans player from the server.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('forcespec', 'forcespectator'), $this, 'command_ForceSpectator', true, 'Forces player into spectator.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('forceplay', $this, 'command_ForcePlay', true, 'Forces player into Play mode.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('forceblue', $this, 'command_ForceBlue', true, 'Forces player into blue team.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('forcered', $this, 'command_ForceRed', true, 'Forces player into red team.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('addbots', 'addbot'), $this, 'command_AddFakePlayers', true, 'Adds bots to the game.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('removebot', 'removebots'), $this, 'command_RemoveFakePlayers', true, 'Removes bots from the game.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('mute', $this, 'command_MutePlayer', true, 'Mutes a player (prevents player from chatting).');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true, 'Unmute a player (enables player to chat again).');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('kick', $this, 'command_Kick', true, 'Kicks player from the server.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('ban', $this, 'command_Ban', true, 'Bans player from the server.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('forcespec', 'forcespectator'), $this, 'command_ForceSpectator', true, 'Forces player into spectator.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('forceplay', $this, 'command_ForcePlay', true, 'Forces player into Play mode.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('forceblue', $this, 'command_ForceBlue', true, 'Forces player into blue team.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('forcered', $this, 'command_ForceRed', true, 'Forces player into red team.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('addbots', 'addbot'), $this, 'command_AddFakePlayers', true, 'Adds bots to the game.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('removebot', 'removebots'), $this, 'command_RemoveFakePlayers', true, 'Removes bots from the game.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('mute', $this, 'command_MutePlayer', true, 'Mutes a player (prevents player from chatting).');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true, 'Unmute a player (enables player to chat again).');
|
||||
|
||||
// Player commands
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('player', 'players'), $this, 'command_playerList', false, 'Shows players currently on the server.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('player', 'players'), $this, 'command_playerList', false, 'Shows players currently on the server.');
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
|
||||
// Action Open PlayerList
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author);
|
||||
$itemQuad->setAction(self::ACTION_OPEN_PLAYERLIST);
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addMenuItem($itemQuad, true, 15, 'Open PlayerList');
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 15, 'Open PlayerList');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,13 +83,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
//Add Balance Team Icon if it's a teamMode
|
||||
if ($teamMode) {
|
||||
// Action Balance Teams
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||
$itemQuad = new Quad_Icons128x32_1();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
||||
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addMenuItem($itemQuad, false, 40, 'Balance Teams');
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, false, 40, 'Balance Teams');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,25 +98,20 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_TeamBalance(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_TEAM_BALANCE)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_TEAM_BALANCE)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->autoTeamBalance();
|
||||
$this->maniaControl->getClient()->autoTeamBalance();
|
||||
} catch (GameModeException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $player);
|
||||
$this->maniaControl->getChat()->sendException($exception, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($player->getEscapedNickname() . ' balanced Teams!');
|
||||
$this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' balanced Teams!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,17 +121,14 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_Kick(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2], 3);
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
@@ -163,9 +136,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->kickPlayer($player->login, $targetLogin, $message);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($player->login, $targetLogin, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,17 +146,14 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_Ban(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2], 3);
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
@@ -193,9 +161,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->banPlayer($player->login, $targetLogin, $message);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player->login, $targetLogin, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,14 +173,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
public function command_Warn(array $chatCallback, Player $player) {
|
||||
$params = explode(' ', $chatCallback[1][2], 3);
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//warn login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//warn login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->warnPlayer($player->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($player->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,30 +187,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForceSpectator(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = (int)$params[2];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
} else {
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToSpectator($player->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,17 +214,14 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForcePlay(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if (!isset($params[1])) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
@@ -279,9 +232,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
}
|
||||
$selectable = ($type === 2);
|
||||
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,24 +242,19 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForceBlue(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if (!isset($params[1])) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,24 +264,19 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForceRed(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if (!isset($params[1])) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,11 +286,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_AddFakePlayers(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$amount = 1;
|
||||
@@ -360,14 +299,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
try {
|
||||
for ($i = 0; $i < $amount; $i++) {
|
||||
$this->maniaControl->getClient()
|
||||
->connectFakePlayer();
|
||||
$this->maniaControl->getClient()->connectFakePlayer();
|
||||
}
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Fake players connected!', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess('Fake players connected!', $player);
|
||||
} catch (UnavailableFeatureException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Error while connecting a Fake-Player.', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess('Error while connecting a Fake-Player.', $player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,17 +314,13 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getClient()
|
||||
->disconnectFakePlayer('*');
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Fake players disconnected!', $player);
|
||||
$this->maniaControl->getClient()->disconnectFakePlayer('*');
|
||||
$this->maniaControl->getChat()->sendSuccess('Fake players disconnected!', $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,14 +332,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
public function command_MutePlayer(array $chatCallback, Player $admin) {
|
||||
$commandParts = explode(' ', $chatCallback[1][2]);
|
||||
if (count($commandParts) <= 1) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No login specified! Example: '//mute login'", $admin);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//mute login'", $admin);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $commandParts[1];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->mutePlayer($admin->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($admin->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,14 +348,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
public function command_UnmutePlayer(array $chatCallback, Player $admin) {
|
||||
$commandParts = explode(' ', $chatCallback[1][2]);
|
||||
if (count($commandParts) <= 1) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendUsageInfo("No login specified! Example: '//unmute login'", $admin);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//unmute login'", $admin);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $commandParts[1];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->unMutePlayer($admin->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($admin->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,11 +362,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_playerList(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerList()
|
||||
->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerList()
|
||||
->showPlayerList($player);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerList()->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerList()->showPlayerList($player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ class PlayerDataManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$defaultType = "'" . self::TYPE_STRING . "'";
|
||||
$typeSet = $defaultType . ",'" . self::TYPE_INT . "','" . self::TYPE_REAL . "','" . self::TYPE_BOOL . "','" . self::TYPE_ARRAY . "'";
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLAYERDATAMETADATA . "` (
|
||||
@@ -104,8 +103,7 @@ class PlayerDataManager {
|
||||
* Store Meta Data from the Database in the Ram
|
||||
*/
|
||||
private function storeMetaData() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
$query = "SELECT * FROM `" . self::TABLE_PLAYERDATAMETADATA . "`;";
|
||||
$result = $mysqli->query($query);
|
||||
@@ -139,8 +137,7 @@ class PlayerDataManager {
|
||||
* @return bool
|
||||
*/
|
||||
public function defineMetaData($object, $dataName, $default, $dataDescription = '') {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$className = ClassUtil::getClass($object);
|
||||
|
||||
$query = "INSERT INTO `" . self::TABLE_PLAYERDATAMETADATA . "` (
|
||||
@@ -218,8 +215,7 @@ class PlayerDataManager {
|
||||
return $this->storedData[$player->index][$meta->dataId];
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$dataQuery = "SELECT `value` FROM `" . self::TABLE_PLAYERDATA . "`
|
||||
WHERE `dataId` = ?
|
||||
AND `playerId` = ?
|
||||
@@ -275,8 +271,7 @@ class PlayerDataManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "INSERT INTO `" . self::TABLE_PLAYERDATA . "` (
|
||||
`serverIndex`,
|
||||
`playerId`,
|
||||
|
||||
@@ -42,18 +42,10 @@ class PlayerDetailed {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$this->height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$this->quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$this->quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$this->width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$this->height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$this->quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$this->quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,17 +56,14 @@ class PlayerDetailed {
|
||||
*/
|
||||
public function showPlayerDetailed(Player $player, $targetLogin) {
|
||||
/** @var Player $target */
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
// Create ManiaLink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$script = $maniaLink->getScript();
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Create script and features
|
||||
@@ -179,8 +168,7 @@ class PlayerDetailed {
|
||||
$label = clone $mainLabel;
|
||||
$frame->add($label);
|
||||
$label->setY($posY);
|
||||
$label->setText($this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($target->authLevel));
|
||||
$label->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel));
|
||||
|
||||
//LadderRank
|
||||
$posY -= 5;
|
||||
@@ -224,8 +212,7 @@ class PlayerDetailed {
|
||||
$quad->setAction(PlayerCommands::ACTION_OPEN_PLAYERLIST);
|
||||
|
||||
// render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'PlayerDetailed');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerDetailed');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,8 +224,7 @@ class PlayerDetailed {
|
||||
public function statisticsFrame(Player $player) {
|
||||
$frame = new Frame();
|
||||
|
||||
$playerStats = $this->maniaControl->getStatisticManager()
|
||||
->getAllPlayerStats($player);
|
||||
$playerStats = $this->maniaControl->getStatisticManager()->getAllPlayerStats($player);
|
||||
$posY = $this->height / 2 - 15;
|
||||
$posX = -$this->width / 2 + 52;
|
||||
$index = 1;
|
||||
|
||||
@@ -74,24 +74,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||
$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->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||
$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');
|
||||
|
||||
// Update Widget Events
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,16 +135,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showPlayerList(Player $player) {
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
// get PlayerList
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
|
||||
//create manialink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@@ -161,9 +148,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@@ -171,9 +156,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$posY = $height / 2;
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@@ -181,13 +164,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 5);
|
||||
$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101);
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
) {
|
||||
$labelLineArray['Actions'] = $posX + 135;
|
||||
}
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $labelLineArray);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $labelLineArray);
|
||||
|
||||
$index = 1;
|
||||
$posY = $height / 2 - 10;
|
||||
@@ -215,8 +196,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
$array = array($index => $posX + 5, $listPlayer->nickname => $posX + 18, $listPlayer->login => $posX + 70, $path => $posX + 101);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($playerFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
|
||||
|
||||
$playerFrame->setY($posY);
|
||||
|
||||
@@ -282,13 +262,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($rightLabel);
|
||||
$rightLabel->setX($posX + 13.9);
|
||||
$rightLabel->setZ(3.1);
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setTextColor('fff');
|
||||
|
||||
$description = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($listPlayer) . ' ' . $listPlayer->nickname;
|
||||
$description = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($listPlayer) . ' ' . $listPlayer->nickname;
|
||||
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
// Player Statistics
|
||||
@@ -326,8 +304,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$description = 'View Player Profile of $<' . $listPlayer->nickname . '$>';
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
) {
|
||||
// Further Player actions Quad
|
||||
$playerQuad = new Quad_Icons64x64_1();
|
||||
@@ -343,11 +320,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getServer()
|
||||
->isTeamMode()
|
||||
if ($this->maniaControl->getServer()->isTeamMode()
|
||||
) {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
) {
|
||||
// Force to Red-Team Quad
|
||||
$redQuad = new Quad_Emblems();
|
||||
@@ -375,8 +350,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
|
||||
$blueQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
} else if ($this->maniaControl->getPluginManager()
|
||||
->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
) {
|
||||
// Kick Player Vote
|
||||
$kickQuad = new Quad_UIConstruction_Buttons();
|
||||
@@ -391,8 +365,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
} else {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
) {
|
||||
// Force to Play
|
||||
$playQuad = new Quad_Emblems();
|
||||
@@ -408,8 +381,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
) {
|
||||
// Force to Spectator Quad
|
||||
$spectatorQuad = new Quad_BgRaceScore2();
|
||||
@@ -423,8 +395,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
// Force to Spectator Description Label
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||
$spectatorQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
} else if ($this->maniaControl->getPluginManager()
|
||||
->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
) {
|
||||
// Force to Spectator Quad
|
||||
$spectatorQuad = new Quad_BgRaceScore2();
|
||||
@@ -452,8 +423,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'PlayerList');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerList');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,20 +434,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @return Frame
|
||||
*/
|
||||
public function showAdvancedPlayerWidget(Player $admin, $login) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
//Settings
|
||||
$posX = $width / 2 + 2.5;
|
||||
@@ -554,9 +515,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$label->setTextSize($textSize);
|
||||
$label->setTextColor($textColor);
|
||||
|
||||
if (!$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->isPlayerMuted($login)
|
||||
if (!$this->maniaControl->getPlayerManager()->getPlayerActions()->isPlayerMuted($login)
|
||||
) {
|
||||
$label->setText('Mute');
|
||||
$quad->setAction(self::ACTION_MUTE_PLAYER . '.' . $login);
|
||||