diff --git a/application/core/Admin/AuthenticationManager.php b/application/core/Admin/AuthenticationManager.php index 150e8c9f..5234474b 100644 --- a/application/core/Admin/AuthenticationManager.php +++ b/application/core/Admin/AuthenticationManager.php @@ -190,6 +190,51 @@ class AuthenticationManager implements CommandListener { } return ($player->authLevel >= $neededAuthLevel); } + + /** + * Get Name of the Authentication Level from Level Int + * + * @param int $authLevelInt + * @return string + */ + public static function getAuthLevelName($authLevelInt) { + if ($authLevelInt == self::AUTH_LEVEL_MASTERADMIN) { + return 'MasterAdmin'; + } + if ($authLevelInt == self::AUTH_LEVEL_SUPERADMIN) { + return 'SuperAdmin'; + } + if ($authLevelInt == self::AUTH_LEVEL_ADMIN) { + return 'Admin'; + } + if ($authLevelInt == self::AUTH_LEVEL_OPERATOR) { + return 'Operator'; + } + return 'Player'; + } + + /** + * Get Authentication Level Int from Level Name + * + * @param string $authLevelName + * @return int + */ + public static function getAuthLevel($authLevelName) { + $authLevelName = strtolower($authLevelName); + if ($authLevelName == 'MasterAdmin') { + return self::AUTH_LEVEL_MASTERADMIN; + } + if ($authLevelName == 'SuperAdmin') { + return self::AUTH_LEVEL_SUPERADMIN; + } + if ($authLevelName == 'Admin') { + return self::AUTH_LEVEL_ADMIN; + } + if ($authLevelName == 'Operator') { + return self::AUTH_LEVEL_OPERATOR; + } + return self::AUTH_LEVEL_PLAYER; + } } ?> diff --git a/application/plugins/Obstacle.php b/application/plugins/Obstacle.php new file mode 100644 index 00000000..0ec87841 --- /dev/null +++ b/application/plugins/Obstacle.php @@ -0,0 +1,57 @@ +maniaControl = $maniaControl; + + // Plugin details + $this->name = 'Obstacle Plugin'; + $this->version = self::VERSION; + $this->author = 'steeffeen'; + $this->description = 'Plugin offering various Commands for the ShootMania Obstacle Game Mode.'; + + // Register for jump command + $this->maniaControl->commandManager->registerCommandListener('jumpto', $this, 'command_JumpTo'); + } + + /** + * Handle JumpTo command + * + * @param array $chatCallback + * @return bool + */ + public function command_JumpTo(array $chatCallback, Player $player) { + // $rightLevel = + if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { + $this->maniaControl->authenticationManager->sendNotAllowed($player); + return false; + } + // Send jump callback + $params = explode(' ', $chatCallback[1][2], 2); + $param = $player->login . ";" . $params[1] . ";"; + if (!$this->maniaControl->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) { + trigger_error("Couldn't send jump callback for '{$player->login}'. " . $this->maniaControl->getClientErrorText()); + } + return true; + } +} + +?>