Esempio n. 1
0
 function __construct($channelData, $permissionsList)
 {
     $this->channelId = (int) $channelData['cid'];
     if (isset(self::$byId[$this->channelId])) {
         self::Erase($this->channelId);
     }
     self::$byId[$this->channelId] = $this;
     if (isset($channelData['pid'])) {
         $this->parentId = (int) $channelData['pid'];
     } else {
         if (isset($channelData['cpid'])) {
             $this->parentId = (int) $channelData['cpid'];
         }
     }
     if (isset($channelData['channel_name'])) {
         $this->name = strval($channelData['channel_name']);
     }
     if (isset($permissionsList['i_channel_needed_join_power'])) {
         $this->joinPower = (int) $permissionsList['i_channel_needed_join_power']['permvalue'];
     }
     if (isset($permissionsList['i_client_needed_talk_power'])) {
         $this->talkPower = (int) $permissionsList['i_client_needed_talk_power']['permvalue'];
     }
     $config = \ManiaLivePlugins\Standard\TeamSpeak\Config::getInstance();
     $actionHandler = \ManiaLive\Gui\ActionHandler::getInstance();
     $tsconnection = \ManiaLivePlugins\Standard\TeamSpeak\Connection::getInstance();
     if ($config->serverChannelPath && $this->getPath() == $config->serverChannelPath) {
         self::$serverIds[self::PATH] = $this->channelId;
     } else {
         if ($this->parentId == self::$serverIds[self::PATH] && $this->name == $config->serverChannelName) {
             self::$serverIds[self::FREE_TALK] = $this->channelId;
             self::$moveActions[self::FREE_TALK] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId);
             foreach (array(self::COMMENTS, self::TEAM_1, self::TEAM_2) as $const) {
                 if (self::$serverIds[$const]) {
                     self::$serverIds[$const] = 0;
                     $actionHandler->deleteAction(self::$moveActions[$const]);
                     self::$moveActions[$const] = null;
                 }
             }
         } else {
             if (self::$serverIds[self::FREE_TALK] && $this->parentId == self::$serverIds[self::FREE_TALK]) {
                 if ($this->joinPower == TeamSpeak::BASIC_POWER) {
                     self::$serverIds[self::TEAM_1] = $this->channelId;
                     self::$moveActions[self::TEAM_1] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId);
                 } else {
                     if ($this->joinPower == TeamSpeak::BASIC_POWER + 1) {
                         self::$serverIds[self::TEAM_2] = $this->channelId;
                         self::$moveActions[self::TEAM_2] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId);
                     } else {
                         if ($this->talkPower == TeamSpeak::BASIC_POWER) {
                             self::$serverIds[self::COMMENTS] = $this->channelId;
                             self::$moveActions[self::COMMENTS] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId);
                         }
                     }
                 }
             }
         }
     }
 }
 function onLoad()
 {
     $config = Config::getInstance();
     if (!$config->serverChannelName) {
         $config->serverChannelName = substr('ManiaPlanet> ' . Formatting::stripStyles($this->connection->getMainServerPlayerInfo()->nickName), 0, 40);
     }
     $this->tsConnection = Connection::getInstance();
     $this->tsConnection->open();
     if (!$this->tsConnection->isConnected()) {
         $this->enableTickerEvent();
     }
     Signal::getInstance()->subscribe('notifyEvent', array($this, 'onTeamSpeakEvent'));
     $this->enableDedicatedEvents(ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT | ServerEvent::ON_PLAYER_INFO_CHANGED);
 }