final function __construct() { $this->dependencies = array(); $this->methods = array(); $this->id = "\\" . get_class($this); $this->setVersion(1); $config = \ManiaLive\DedicatedApi\Config::getInstance(); $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password); $this->pluginHandler = PluginHandler::getInstance(); $this->storage = Storage::getInstance(); $this->chatCommands = array(); }
function onDialogClosed($login, \ManiaLive\Gui\Window $dialog) { if ($dialog->getAnswer() == Dialog::YES) { if (Storage::getInstance()->serverStatus->code == 4) { $config = \ManiaLive\DedicatedApi\Config::getInstance(); Connection::factory($config->host, $config->port)->restartMap(); $this->hide(); } else { $dialog->showModal(); } } }
function getConnectUrl($login) { $player = \ManiaLive\Data\Storage::getInstance()->getPlayerObject($login); $queryArgs = 'nickname=' . rawurlencode(substr(\ManiaLib\Utils\Formatting::stripStyles($player->nickName), 0, 30)); if ($channel = Structures\Channel::GetDefault()) { $queryArgs .= '&channel=' . rawurlencode($channel->getPath()); } $queryArgs .= '&token=' . rawurlencode(Connection::getInstance()->getToken($login)); if ($this->voicePassword) { $queryArgs .= '&password='******'ts3server://' . $this->voiceHost . ':' . $this->voicePort . '?' . $queryArgs; }
static function addPlayer($login, $nickName = null, $ladderPoints = 0, $state = 0, $uniqLogin = true) { $storage = \ManiaLive\Data\Storage::getInstance(); try { $player = array('login' => $login, 'nickname' => $nickName ?: $login, 'ladderPoints' => $ladderPoints, 'state' => $state); if ($uniqLogin) { static::$playerList[$login] = $player; } else { array_unshift(static::$playerList, $player); } } catch (\Exception $e) { return; } }
protected function init() { new \ManiaLive\Features\Tick\Ticker(); $config = \ManiaLive\DedicatedApi\Config::getInstance(); $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password); $this->connection->enableCallbacks(true); \ManiaLive\Data\Storage::getInstance(); \ManiaLive\Features\ChatCommand\Interpreter::getInstance(); \ManiaLive\Features\EchoHandler::getInstance(); \ManiaLive\Gui\GuiHandler::getInstance(); \ManiaLive\PluginHandler\PluginHandler::getInstance(); \ManiaLive\Threading\ThreadHandler::getInstance(); Dispatcher::dispatch(new Event(Event::ON_INIT)); }
final function __construct() { $this->dependencies = array(); $this->methods = array(); $items = explode('\\', get_class($this)); $this->author = $items[1]; $this->name = $items[2]; $this->id = $this->author . '\\' . $this->name; $this->setVersion(1); $config = \ManiaLive\DedicatedApi\Config::getInstance(); $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password); $this->pluginHandler = PluginHandler::getInstance(); $this->storage = Storage::getInstance(); $this->chatCommands = array(); }
function showMatchSumUp(Match $match, $receiver, $time) { $storage = Storage::getInstance(); $getPlayerInfosCallback = function ($login) use($storage) { $p = $storage->getPlayerObject($login); $pathArray = explode('|', $p->ladderStats['PlayerRankings'][0]['Path']); $path = implode('|', array_slice($pathArray, 0, 3)); return (object) array('login' => $login, 'nickname' => $p ? $p->nickName : $login, 'zone' => $p ? array_pop($pathArray) : 'World', 'rank' => $p ? $p->ladderStats['PlayerRankings'][0]['Ranking'] : -1, 'zoneFlag' => sprintf('file://ZoneFlags/Login/%s/country', $login), 'ladderPoints' => $p->ladderStats['PlayerRankings'][0]['Score'], 'echelon' => \ManiaLivePlugins\MatchMakingLobby\Services\PlayerInfo::ComputeEchelon($p->ladderStats['PlayerRankings'][0]['Score'])); }; $sortPlayerCallback = function ($player1, $player2) { if ($player1->ladderPoints == $player2->ladderPoints) { return 0; } return $player1->ladderPoints < $player2->ladderPoints ? 1 : -1; }; $players = array_map($getPlayerInfosCallback, $match->players); usort($players, $sortPlayerCallback); $window = \ManiaLivePlugins\MatchMakingLobby\Windows\StartSoloMatch::Create($receiver); $window->set($players, $time); $window->show(); }
function createParty($playersLogin, $disabledPlayersLogin = array()) { foreach ($playersLogin as $login) { $playerObject = \ManiaLive\Data\Storage::getInstance()->getPlayerObject($login); if ($playerObject) { $this->addPlayerToParty($playerObject); } } foreach ($disabledPlayersLogin as $login) { $playerObject = \ManiaLive\Data\Storage::getInstance()->getPlayerObject($login); if ($playerObject) { $this->addPlayerToParty($playerObject, true); } } }
private function register($pluginId) { if (isset($this->loadedPlugins[$pluginId]) || isset($this->delayedPlugins[$pluginId])) { throw new Exception('Plugin "' . $pluginId . '" cannot be loaded, maybe there is a naming conflict!'); } $parts = explode('\\', $pluginId); $className = '\\ManiaLivePlugins\\' . $pluginId . '\\' . end($parts); if (!class_exists($className)) { $className = '\\ManiaLivePlugins\\' . $pluginId . '\\Plugin'; if (!class_exists($className)) { throw new Exception('Plugin "' . $pluginId . '" not found!'); } } $plugin = new $className(); $plugin->onInit(); if (Storage::getInstance()->serverStatus->code > Status::LAUNCHING || $plugin instanceof WaitingCompliant) { Console::println('[PluginHandler] Loading plugin "' . $pluginId . '" ' . $plugin->getVersion() . '...'); return $this->loadedPlugins[$pluginId] = $plugin; } Console::println('[PluginHandler] Server is waiting, plugin "' . $pluginId . '" will be loaded later...'); $this->delayedPlugins[$pluginId] = $plugin; return null; }
static function IsClientAllowed($client, $channelId) { $player = \ManiaLive\Data\Storage::getInstance()->getPlayerObject($client->login); if ($player && $player->teamId != -1) { return $channelId == self::$serverIds[$player->teamId] || $channelId == self::$serverIds[self::PATH] || !in_array($channelId, self::$serverIds); } return $channelId != self::$serverIds[self::TEAM_1] && $channelId != self::$serverIds[self::TEAM_2]; }
function onTerminate() { if (Storage::getInstance()->serverStatus->code > Status::LAUNCHING) { $this->connection->sendHideManialinkPage(); } }
protected function isPlayerConnected($login) { $p = \ManiaLive\Data\Storage::getInstance()->getPlayerObject($login); return $p && $p->isConnected !== false ? true : false; }
/** * update the Player list * @param string $login * @param string[] $blockedPlayerList */ final function updatePlayerList(array $blockedPlayerList, $setLocalAllyAction, $unsetLocalAllyAction, $maxAllyCount, $player = '') { if ($player) { $playerLists = Windows\PlayerList::Get($player); } else { $playerLists = Windows\PlayerList::GetAll(); } foreach ($playerLists as $playerList) { $recipient = $playerList->getRecipient(); $allies = \ManiaLivePlugins\MatchMakingLobby\Services\AllyService::getInstance()->getAll($recipient); $loginsWithUnsetAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a) { if ($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_LOCAL) { return $a->login; } }, $allies); $loginsWithNoAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a) { if ($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_GENERAL) { return $a->login; } }, $allies); $bilateralAllies = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a) { if ($a->isBilateral) { return $a->login; } }, $allies); $storage = Storage::getInstance(); foreach (array_merge($storage->players, $storage->spectators) as $player) { if (PlayerInfo::Get($player->login)->isAway()) { continue; } $ladderPoints = $player->ladderStats['PlayerRankings'][0]['Score']; $playerInfo = PlayerInfo::Get($player->login); $state = Player::STATE_NOT_READY; if ($playerInfo->isReady()) { $state = Player::STATE_READY; } if ($playerInfo->isInMatch) { $state = Player::STATE_IN_MATCH; } if (array_key_exists($player->login, $blockedPlayerList)) { $state = Player::STATE_BLOCKED; } if ($player->login == $recipient) { $action = null; $isAlly = false; } elseif (in_array($player->login, $loginsWithNoAction)) { $action = null; $isAlly = true; } elseif (in_array($player->login, $loginsWithUnsetAction)) { $action = $unsetLocalAllyAction; $isAlly = true; } else { $action = count($allies) >= $maxAllyCount ? null : $setLocalAllyAction; $isAlly = false; } $isBilateral = in_array($player->login, $bilateralAllies); $playerList->setPlayer($player->login, $player->nickName, $ladderPoints, $state, $action, $isAlly, $isBilateral); } } Windows\PlayerList::RedrawAll(); }