prepare method
This commit is contained in:
parent
053649600d
commit
be86717c0b
@ -15,10 +15,18 @@ interface Plugin {
|
|||||||
*/
|
*/
|
||||||
const PLUGIN_INTERFACE = __CLASS__;
|
const PLUGIN_INTERFACE = __CLASS__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl);
|
public function load(ManiaControl $maniaControl);
|
||||||
|
@ -30,6 +30,16 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use ManiaControl\FileUtil;
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\FileUtil;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,39 +14,48 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ID = 1;
|
const ID = 1;
|
||||||
const VERSION = 0.1;
|
const VERSION = 0.1;
|
||||||
const DATE = 'd-m-y h:i:sa T';
|
const DATE = 'd-m-y h:i:sa T';
|
||||||
const SETTING_FOLDERNAME = 'Log-Folder Name';
|
const SETTING_FOLDERNAME = 'Log-Folder Name';
|
||||||
const SETTING_FILENAME = 'Log-File Name';
|
const SETTING_FILENAME = 'Log-File Name';
|
||||||
const SETTING_USEPID = 'Use Process-Id for File Name';
|
const SETTING_USEPID = 'Use Process-Id for File Name';
|
||||||
const SETTING_LOGSERVERMESSAGES = 'Log Server Messages';
|
const SETTING_LOGSERVERMESSAGES = 'Log Server Messages';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
/** @var maniaControl $maniaControl */
|
/** @var maniaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $fileName = null;
|
private $fileName = null;
|
||||||
private $logServerMessages = true;
|
private $logServerMessages = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
*
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_FOLDERNAME, 'logs');
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_FOLDERNAME, 'logs');
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_FILENAME, 'ChatLog.log');
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_FILENAME, 'ChatLog.log');
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_USEPID, false);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_USEPID, false);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LOGSERVERMESSAGES, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LOGSERVERMESSAGES, true);
|
||||||
|
|
||||||
// Get settings
|
// Get settings
|
||||||
$folderName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FOLDERNAME);
|
$folderName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FOLDERNAME);
|
||||||
$folderName = FileUtil::getClearedFileName($folderName);
|
$folderName = FileUtil::getClearedFileName($folderName);
|
||||||
$folderDir = ManiaControlDir . '/' . $folderName;
|
$folderDir = ManiaControlDir . '/' . $folderName;
|
||||||
if (!is_dir($folderDir)) {
|
if (!is_dir($folderDir)) {
|
||||||
$success = mkdir($folderDir);
|
$success = mkdir($folderDir);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
@ -55,29 +64,26 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
$fileName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FILENAME);
|
$fileName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FILENAME);
|
||||||
$fileName = FileUtil::getClearedFileName($fileName);
|
$fileName = FileUtil::getClearedFileName($fileName);
|
||||||
$usePId = $this->maniaControl->settingManager->getSetting($this, self::SETTING_USEPID);
|
$usePId = $this->maniaControl->settingManager->getSetting($this, self::SETTING_USEPID);
|
||||||
if ($usePId) {
|
if ($usePId) {
|
||||||
$dotIndex = strripos($fileName, '.');
|
$dotIndex = strripos($fileName, '.');
|
||||||
$pIdPart = '_' . getmypid();
|
$pIdPart = '_' . getmypid();
|
||||||
if ($dotIndex !== false && $dotIndex >= 0) {
|
if ($dotIndex !== false && $dotIndex >= 0) {
|
||||||
$fileName = substr($fileName, 0, $dotIndex) . $pIdPart . substr($fileName, $dotIndex);
|
$fileName = substr($fileName, 0, $dotIndex) . $pIdPart . substr($fileName, $dotIndex);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$fileName .= $pIdPart;
|
$fileName .= $pIdPart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->fileName = $folderDir . '/' . $fileName;
|
$this->fileName = $folderDir . '/' . $fileName;
|
||||||
$this->logServerMessages = $this->maniaControl->settingManager->getSetting($this, self::SETTING_LOGSERVERMESSAGES);
|
$this->logServerMessages = $this->maniaControl->settingManager->getSetting($this, self::SETTING_LOGSERVERMESSAGES);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
|
||||||
'handlePlayerChatCallback');
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
@ -86,7 +92,6 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*/
|
*/
|
||||||
public static function getId() {
|
public static function getId() {
|
||||||
@ -94,7 +99,6 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getName() {
|
||||||
@ -102,7 +106,6 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
*/
|
*/
|
||||||
public static function getVersion() {
|
public static function getVersion() {
|
||||||
@ -110,7 +113,6 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getAuthor() {
|
||||||
@ -118,7 +120,6 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
*/
|
*/
|
||||||
public static function getDescription() {
|
public static function getDescription() {
|
||||||
@ -128,7 +129,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle PlayerChat callback
|
* Handle PlayerChat callback
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerChatCallback(array $chatCallback) {
|
public function handlePlayerChatCallback(array $chatCallback) {
|
||||||
$data = $chatCallback[1];
|
$data = $chatCallback[1];
|
||||||
@ -142,8 +143,8 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Log the given message
|
* Log the given message
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param string $login
|
* @param string $login
|
||||||
*/
|
*/
|
||||||
private function logText($text, $login = null) {
|
private function logText($text, $login = null) {
|
||||||
if (!$login) {
|
if (!$login) {
|
||||||
|
@ -84,6 +84,16 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
/** @var Player $voter */
|
/** @var Player $voter */
|
||||||
private $voter = null;
|
private $voter = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
|
@ -43,6 +43,16 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
const SETTING_DONATION_VALUES = 'Donation Values';
|
const SETTING_DONATION_VALUES = 'Donation Values';
|
||||||
const SETTING_MIN_AMOUNT_SHOWN = 'Minimum Donation amount to get shown';
|
const SETTING_MIN_AMOUNT_SHOWN = 'Minimum Donation amount to get shown';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
@ -27,6 +27,16 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
|
|||||||
const DYNPNT_MIN = 'Minimum pointlimit';
|
const DYNPNT_MIN = 'Minimum pointlimit';
|
||||||
const DYNPNT_MAX = 'Maximum pointlimit';
|
const DYNPNT_MAX = 'Maximum pointlimit';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,16 @@ class EndurancePlugin implements CallbackListener, Plugin {
|
|||||||
private $currentMap = null;
|
private $currentMap = null;
|
||||||
private $playerLapTimes = array();
|
private $playerLapTimes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
|
@ -45,6 +45,16 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
private $manialink = null;
|
private $manialink = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
|
@ -45,6 +45,16 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
|
@ -29,6 +29,16 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
/** @var maniaControl $maniaControl */
|
/** @var maniaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
|
@ -45,6 +45,16 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
|||||||
private $spectators = array();
|
private $spectators = array();
|
||||||
private $showPlay = array();
|
private $showPlay = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
|
@ -5,13 +5,12 @@ use FML\Controls\Labels\Label_Text;
|
|||||||
use FML\Controls\Quad;
|
use FML\Controls\Quad;
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
|
||||||
@ -22,483 +21,499 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
*
|
*
|
||||||
* @author TheM
|
* @author TheM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPageAnswerListener, Plugin {
|
class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPageAnswerListener, Plugin {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ID = 11;
|
const ID = 11;
|
||||||
const VERSION = 0.1;
|
const VERSION = 0.1;
|
||||||
|
|
||||||
const TEAMSPEAK_SID = 'TS Server ID';
|
const TEAMSPEAK_SID = 'TS Server ID';
|
||||||
const TEAMSPEAK_SERVERHOST = 'TS Server host';
|
const TEAMSPEAK_SERVERHOST = 'TS Server host';
|
||||||
const TEAMSPEAK_SERVERPORT = 'TS Server port';
|
const TEAMSPEAK_SERVERPORT = 'TS Server port';
|
||||||
const TEAMSPEAK_QUERYHOST = 'TS Server Query host';
|
const TEAMSPEAK_QUERYHOST = 'TS Server Query host';
|
||||||
const TEAMSPEAK_QUERYPORT = 'TS Server Query port';
|
const TEAMSPEAK_QUERYPORT = 'TS Server Query port';
|
||||||
const TEAMSPEAK_QUERYUSER = 'TS Server Query user';
|
const TEAMSPEAK_QUERYUSER = 'TS Server Query user';
|
||||||
const TEAMSPEAK_QUERYPASS = 'TS Server Query password';
|
const TEAMSPEAK_QUERYPASS = 'TS Server Query password';
|
||||||
|
|
||||||
const ACTION_OPEN_TSVIEWER = 'TSViewer.OpenWidget';
|
const ACTION_OPEN_TSVIEWER = 'TSViewer.OpenWidget';
|
||||||
|
|
||||||
const TS_ICON = 'Teamspeak.png';
|
const TS_ICON = 'Teamspeak.png';
|
||||||
const TS_ICON_MOVER = 'Teamspeak_logo_press.png';
|
const TS_ICON_MOVER = 'Teamspeak_logo_press.png';
|
||||||
const TS_ICON_LINK = 'http://dump.klaversma.eu';
|
const TS_ICON_LINK = 'http://dump.klaversma.eu';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
/** @var ManiaControl $maniaControl */
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $serverData = array();
|
private $serverData = array();
|
||||||
private $refreshTime = 0;
|
private $refreshTime = 0;
|
||||||
private $refreshInterval = 90;
|
private $refreshInterval = 90;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Prepares the Plugin
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
* @param ManiaControl $maniaControl
|
||||||
* @return bool
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
// TODO: Implement prepare() method.
|
||||||
$this->addConfigs();
|
}
|
||||||
$this->checkConfig();
|
|
||||||
|
|
||||||
$this->refreshTime = time();
|
/**
|
||||||
|
* Load the plugin
|
||||||
|
*
|
||||||
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function load(ManiaControl $maniaControl) {
|
||||||
|
$this->maniaControl = $maniaControl;
|
||||||
|
$this->addConfigs();
|
||||||
|
$this->checkConfig();
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON, self::TS_ICON_LINK);
|
$this->refreshTime = time();
|
||||||
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON_MOVER, self::TS_ICON_LINK);
|
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'ts3_queryServer');
|
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON, self::TS_ICON_LINK);
|
||||||
|
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON_MOVER, self::TS_ICON_LINK);
|
||||||
|
|
||||||
$this->addToMenu();
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'ts3_queryServer');
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$this->addToMenu();
|
||||||
* Function used to add the configuration options to the settings manager.
|
}
|
||||||
*/
|
|
||||||
private function addConfigs() {
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SID, 1);
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SERVERHOST, 'ts3.somehoster.com');
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SERVERPORT, 9987);
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYHOST, '');
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYPORT, 10011);
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYUSER, '');
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYPASS, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to check certain configuration options to check if they can be used.
|
* Function used to add the configuration options to the settings manager.
|
||||||
*
|
*/
|
||||||
* @throws Exception
|
private function addConfigs() {
|
||||||
*/
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SID, 1);
|
||||||
private function checkConfig() {
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SERVERHOST, 'ts3.somehoster.com');
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) == 'ts3.somehoster.com') {
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SERVERPORT, 9987);
|
||||||
$error = 'Missing the required serverhost, please set it up before enabling the TeamSpeak plugin!';
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYHOST, '');
|
||||||
throw new Exception($error);
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYPORT, 10011);
|
||||||
}
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYUSER, '');
|
||||||
|
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYPASS, '');
|
||||||
|
}
|
||||||
|
|
||||||
$this->ts3_queryServer(); // Get latest information from the TeamSpeak server
|
/**
|
||||||
if(!isset($this->serverData['channels']) || count($this->serverData['channels']) == 0) {
|
* Function used to check certain configuration options to check if they can be used.
|
||||||
$error = 'Could not make proper connections with the server!';
|
*
|
||||||
throw new Exception($error);
|
* @throws Exception
|
||||||
}
|
*/
|
||||||
}
|
private function checkConfig() {
|
||||||
|
if ($this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) == 'ts3.somehoster.com') {
|
||||||
|
$error = 'Missing the required serverhost, please set it up before enabling the TeamSpeak plugin!';
|
||||||
|
throw new Exception($error);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
$this->ts3_queryServer(); // Get latest information from the TeamSpeak server
|
||||||
* Function used insert the icon into the menu.
|
if (!isset($this->serverData['channels']) || count($this->serverData['channels']) == 0) {
|
||||||
*/
|
$error = 'Could not make proper connections with the server!';
|
||||||
private function addToMenu() {
|
throw new Exception($error);
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_TSVIEWER, $this, 'command_tsViewer');
|
}
|
||||||
$itemQuad = new Quad();
|
}
|
||||||
$itemQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(self::TS_ICON));
|
|
||||||
$itemQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(self::TS_ICON_MOVER));
|
|
||||||
$itemQuad->setAction(self::ACTION_OPEN_TSVIEWER);
|
|
||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 1, 'Open TeamSpeak Viewer');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload the plugin and its resources
|
* Function used insert the icon into the menu.
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
private function addToMenu() {
|
||||||
$this->serverData = array();
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_TSVIEWER, $this, 'command_tsViewer');
|
||||||
$this->lastRequest = null;
|
$itemQuad = new Quad();
|
||||||
|
$itemQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(self::TS_ICON));
|
||||||
|
$itemQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(self::TS_ICON_MOVER));
|
||||||
|
$itemQuad->setAction(self::ACTION_OPEN_TSVIEWER);
|
||||||
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 1, 'Open TeamSpeak Viewer');
|
||||||
|
}
|
||||||
|
|
||||||
$this->maniaControl->actionsMenu->removeMenuItem(1, true);
|
/**
|
||||||
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($this);
|
* Unload the plugin and its resources
|
||||||
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
*/
|
||||||
$this->maniaControl->commandManager->unregisterCommandListener($this);
|
public function unload() {
|
||||||
$this->maniaControl = null;
|
$this->serverData = array();
|
||||||
}
|
$this->lastRequest = null;
|
||||||
|
|
||||||
/**
|
$this->maniaControl->actionsMenu->removeMenuItem(1, true);
|
||||||
* Get plugin id
|
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($this);
|
||||||
*
|
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||||
* @return int
|
$this->maniaControl->commandManager->unregisterCommandListener($this);
|
||||||
*/
|
$this->maniaControl = null;
|
||||||
public static function getId() {
|
}
|
||||||
return self::ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Name
|
* Get plugin id
|
||||||
*
|
*
|
||||||
* @return string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getId() {
|
||||||
return 'TeamSpeak Plugin';
|
return self::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Version
|
* Get Plugin Name
|
||||||
*
|
*
|
||||||
* @return float
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getVersion() {
|
public static function getName() {
|
||||||
return self::VERSION;
|
return 'TeamSpeak Plugin';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Author
|
* Get Plugin Version
|
||||||
*
|
*
|
||||||
* @return string
|
* @return float
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getVersion() {
|
||||||
return 'TheM';
|
return self::VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Description
|
* Get Plugin Author
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getDescription() {
|
public static function getAuthor() {
|
||||||
return 'Plugin offers a connection with a TeamSpeak server (via widgets).';
|
return 'TheM';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function handling the pressing of the icon.
|
* Get Plugin Description
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @return string
|
||||||
* @param Player $player
|
*/
|
||||||
*/
|
public static function getDescription() {
|
||||||
public function command_tsViewer(array $chatCallback, Player $player) {
|
return 'Plugin offers a connection with a TeamSpeak server (via widgets).';
|
||||||
$this->showWidget($player);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function showing the TeamSpeak widget to the player.
|
* Function handling the pressing of the icon.
|
||||||
*
|
*
|
||||||
* @param $player
|
* @param array $chatCallback
|
||||||
*/
|
* @param Player $player
|
||||||
private function showWidget($player) {
|
*/
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
public function command_tsViewer(array $chatCallback, Player $player) {
|
||||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
$this->showWidget($player);
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
}
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
|
||||||
|
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
/**
|
||||||
|
* Function showing the TeamSpeak widget to the player.
|
||||||
|
*
|
||||||
|
* @param $player
|
||||||
|
*/
|
||||||
|
private function showWidget($player) {
|
||||||
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
// Main frame
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$frame = new Frame();
|
|
||||||
$maniaLink->add($frame);
|
|
||||||
$frame->setSize($width, $height);
|
|
||||||
$frame->setPosition(0, 0, 10);
|
|
||||||
|
|
||||||
// Background
|
// Main frame
|
||||||
$backgroundQuad = new Quad();
|
$frame = new Frame();
|
||||||
$frame->add($backgroundQuad);
|
$maniaLink->add($frame);
|
||||||
$backgroundQuad->setSize($width, $height);
|
$frame->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$frame->setPosition(0, 0, 10);
|
||||||
|
|
||||||
// Close Quad (X)
|
// Background
|
||||||
$closeQuad = new Quad_Icons64x64_1();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($closeQuad);
|
$frame->add($backgroundQuad);
|
||||||
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$closeQuad->setSize(6, 6);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
|
||||||
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
|
||||||
|
|
||||||
$servername = new Label_Text();
|
// Close Quad (X)
|
||||||
$frame->add($servername);
|
$closeQuad = new Quad_Icons64x64_1();
|
||||||
$servername->setY($height / 2 - 4);
|
$frame->add($closeQuad);
|
||||||
$servername->setX(-70);
|
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3);
|
||||||
$servername->setStyle($servername::STYLE_TextCardMedium);
|
$closeQuad->setSize(6, 6);
|
||||||
$servername->setHAlign('left');
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||||
$servername->setTextSize(1);
|
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||||
$servername->setText('$oServername:$o '.$this->serverData['server']['virtualserver_name']);
|
|
||||||
$servername->setTextColor('fff');
|
|
||||||
|
|
||||||
$serverversion = new Label_Text();
|
$servername = new Label_Text();
|
||||||
$frame->add($serverversion);
|
$frame->add($servername);
|
||||||
$serverversion->setY($height / 2 - 4);
|
$servername->setY($height / 2 - 4);
|
||||||
$serverversion->setX(2);
|
$servername->setX(-70);
|
||||||
$serverversion->setStyle($serverversion::STYLE_TextCardMedium);
|
$servername->setStyle($servername::STYLE_TextCardMedium);
|
||||||
$serverversion->setHAlign('left');
|
$servername->setHAlign('left');
|
||||||
$serverversion->setTextSize(1);
|
$servername->setTextSize(1);
|
||||||
$serverversion->setText('$oServerversion:$o '.$this->serverData['server']['virtualserver_version']);
|
$servername->setText('$oServername:$o ' . $this->serverData['server']['virtualserver_name']);
|
||||||
$serverversion->setTextColor('fff');
|
$servername->setTextColor('fff');
|
||||||
|
|
||||||
$clients = new Label_Text();
|
$serverversion = new Label_Text();
|
||||||
$frame->add($clients);
|
$frame->add($serverversion);
|
||||||
$clients->setY($height / 2 - 7);
|
$serverversion->setY($height / 2 - 4);
|
||||||
$clients->setX(-70);
|
$serverversion->setX(2);
|
||||||
$clients->setStyle($clients::STYLE_TextCardMedium);
|
$serverversion->setStyle($serverversion::STYLE_TextCardMedium);
|
||||||
$clients->setHAlign('left');
|
$serverversion->setHAlign('left');
|
||||||
$clients->setTextSize(1);
|
$serverversion->setTextSize(1);
|
||||||
$clients->setText('$oConnected clients:$o '.$this->serverData['server']['virtualserver_clientsonline'].'/'.$this->serverData['server']['virtualserver_maxclients']);
|
$serverversion->setText('$oServerversion:$o ' . $this->serverData['server']['virtualserver_version']);
|
||||||
$clients->setTextColor('fff');
|
$serverversion->setTextColor('fff');
|
||||||
|
|
||||||
$channels = new Label_Text();
|
$clients = new Label_Text();
|
||||||
$frame->add($channels);
|
$frame->add($clients);
|
||||||
$channels->setY($height / 2 - 7);
|
$clients->setY($height / 2 - 7);
|
||||||
$channels->setX(2);
|
$clients->setX(-70);
|
||||||
$channels->setStyle($channels::STYLE_TextCardMedium);
|
$clients->setStyle($clients::STYLE_TextCardMedium);
|
||||||
$channels->setHAlign('left');
|
$clients->setHAlign('left');
|
||||||
$channels->setTextSize(1);
|
$clients->setTextSize(1);
|
||||||
$nochannels = 0;
|
$clients->setText('$oConnected clients:$o ' . $this->serverData['server']['virtualserver_clientsonline'] . '/' . $this->serverData['server']['virtualserver_maxclients']);
|
||||||
foreach($this->serverData['channels'] as $channel) {
|
$clients->setTextColor('fff');
|
||||||
if($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) continue;
|
|
||||||
$nochannels++;
|
|
||||||
}
|
|
||||||
$channels->setText('$oChannels:$o '.$nochannels);
|
|
||||||
$channels->setTextColor('fff');
|
|
||||||
|
|
||||||
// Join button
|
$channels = new Label_Text();
|
||||||
$joinbutton = new Label_Button();
|
$frame->add($channels);
|
||||||
$frame->add($joinbutton);
|
$channels->setY($height / 2 - 7);
|
||||||
$joinbutton->setWidth(150);
|
$channels->setX(2);
|
||||||
$joinbutton->setY($height / 2 - 11.5);
|
$channels->setStyle($channels::STYLE_TextCardMedium);
|
||||||
$joinbutton->setStyle($joinbutton::STYLE_CardButtonSmallWide);
|
$channels->setHAlign('left');
|
||||||
$joinbutton->setText('Join TeamSpeak: '.$this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST).':'.$this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERPORT));
|
$channels->setTextSize(1);
|
||||||
$joinbutton->setTextColor('fff');
|
$nochannels = 0;
|
||||||
$url = 'ts3server://'. $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) .'/?port='. $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERPORT) .'&nickname='. rawurlencode(\ManiaControl\Formatter::stripCodes($player->nickname));
|
foreach($this->serverData['channels'] as $channel) {
|
||||||
$joinbutton->setUrl($url);
|
if ($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$nochannels++;
|
||||||
|
}
|
||||||
|
$channels->setText('$oChannels:$o ' . $nochannels);
|
||||||
|
$channels->setTextColor('fff');
|
||||||
|
|
||||||
$leftlistQuad = new Quad();
|
// Join button
|
||||||
$frame->add($leftlistQuad);
|
$joinbutton = new Label_Button();
|
||||||
$leftlistQuad->setSize((($width/2)-5), ($height-18));
|
$frame->add($joinbutton);
|
||||||
$leftlistQuad->setX(-36);
|
$joinbutton->setWidth(150);
|
||||||
$leftlistQuad->setY($height / 2 - 46);
|
$joinbutton->setY($height / 2 - 11.5);
|
||||||
$leftlistQuad->setStyles($quadStyle, $quadSubstyle);
|
$joinbutton->setStyle($joinbutton::STYLE_CardButtonSmallWide);
|
||||||
|
$joinbutton->setText('Join TeamSpeak: ' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) . ':' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERPORT));
|
||||||
|
$joinbutton->setTextColor('fff');
|
||||||
|
$url = 'ts3server://' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) . '/?port=' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERPORT) . '&nickname=' . rawurlencode(\ManiaControl\Formatter::stripCodes($player->nickname));
|
||||||
|
$joinbutton->setUrl($url);
|
||||||
|
|
||||||
$channels = array();
|
$leftlistQuad = new Quad();
|
||||||
$users = array();
|
$frame->add($leftlistQuad);
|
||||||
$userid = 0;
|
$leftlistQuad->setSize((($width / 2) - 5), ($height - 18));
|
||||||
$i = 0;
|
$leftlistQuad->setX(-36);
|
||||||
$startx = -69.5;
|
$leftlistQuad->setY($height / 2 - 46);
|
||||||
foreach($this->serverData['channels'] as $channel) {
|
$leftlistQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
if($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) continue;
|
|
||||||
$channels[$i] = new Label_Text();
|
|
||||||
$frame->add($channels[$i]);
|
|
||||||
$y = 17.5+($i*2.5);
|
|
||||||
$channels[$i]->setY($height / 2 - $y);
|
|
||||||
$x = $startx;
|
|
||||||
if($channel['pid'] != 0) {
|
|
||||||
$x = $startx+5;
|
|
||||||
}
|
|
||||||
$channels[$i]->setX($x);
|
|
||||||
$channels[$i]->setStyle($channels[$i]::STYLE_TextCardMedium);
|
|
||||||
$channels[$i]->setHAlign('left');
|
|
||||||
$channels[$i]->setTextSize(1);
|
|
||||||
$channels[$i]->setScale(0.9);
|
|
||||||
if($channel['channel_flag_default'] == 1) $channel['total_clients'] = ($channel['total_clients']-1); // remove query client
|
|
||||||
$channels[$i]->setText('$o'.$channel['channel_name'].'$o ('.$channel['total_clients'].')');
|
|
||||||
$channels[$i]->setTextColor('fff');
|
|
||||||
|
|
||||||
$i++;
|
$channels = array();
|
||||||
foreach($this->serverData['users'] as $user) {
|
$users = array();
|
||||||
if($user['cid'] == $channel['cid']) {
|
$userid = 0;
|
||||||
$users[$userid] = new Label_Text();
|
$i = 0;
|
||||||
$frame->add($users[$userid]);
|
$startx = -69.5;
|
||||||
$y = 17.5+($i*2.5);
|
foreach($this->serverData['channels'] as $channel) {
|
||||||
$users[$userid]->setY($height / 2 - $y);
|
if ($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) {
|
||||||
$x = $startx;
|
continue;
|
||||||
if($channel['pid'] != 0) {
|
}
|
||||||
$x = $startx+7;
|
$channels[$i] = new Label_Text();
|
||||||
} else {
|
$frame->add($channels[$i]);
|
||||||
$x = $startx+2;
|
$y = 17.5 + ($i * 2.5);
|
||||||
}
|
$channels[$i]->setY($height / 2 - $y);
|
||||||
$users[$userid]->setX($x);
|
$x = $startx;
|
||||||
$users[$userid]->setStyle($users[$userid]::STYLE_TextCardMedium);
|
if ($channel['pid'] != 0) {
|
||||||
$users[$userid]->setHAlign('left');
|
$x = $startx + 5;
|
||||||
$users[$userid]->setTextSize(1);
|
}
|
||||||
$users[$userid]->setScale(0.9);
|
$channels[$i]->setX($x);
|
||||||
$users[$userid]->setText($user['client_nickname']);
|
$channels[$i]->setStyle($channels[$i]::STYLE_TextCardMedium);
|
||||||
$users[$userid]->setTextColor('fff');
|
$channels[$i]->setHAlign('left');
|
||||||
$userid++;
|
$channels[$i]->setTextSize(1);
|
||||||
$i++;
|
$channels[$i]->setScale(0.9);
|
||||||
|
if ($channel['channel_flag_default'] == 1) {
|
||||||
|
$channel['total_clients'] = ($channel['total_clients'] - 1);
|
||||||
|
} // remove query client
|
||||||
|
$channels[$i]->setText('$o' . $channel['channel_name'] . '$o (' . $channel['total_clients'] . ')');
|
||||||
|
$channels[$i]->setTextColor('fff');
|
||||||
|
|
||||||
if($i > 22) {
|
$i++;
|
||||||
$i = 0;
|
foreach($this->serverData['users'] as $user) {
|
||||||
$startx = 2.5;
|
if ($user['cid'] == $channel['cid']) {
|
||||||
}
|
$users[$userid] = new Label_Text();
|
||||||
}
|
$frame->add($users[$userid]);
|
||||||
}
|
$y = 17.5 + ($i * 2.5);
|
||||||
|
$users[$userid]->setY($height / 2 - $y);
|
||||||
|
$x = $startx;
|
||||||
|
if ($channel['pid'] != 0) {
|
||||||
|
$x = $startx + 7;
|
||||||
|
} else {
|
||||||
|
$x = $startx + 2;
|
||||||
|
}
|
||||||
|
$users[$userid]->setX($x);
|
||||||
|
$users[$userid]->setStyle($users[$userid]::STYLE_TextCardMedium);
|
||||||
|
$users[$userid]->setHAlign('left');
|
||||||
|
$users[$userid]->setTextSize(1);
|
||||||
|
$users[$userid]->setScale(0.9);
|
||||||
|
$users[$userid]->setText($user['client_nickname']);
|
||||||
|
$users[$userid]->setTextColor('fff');
|
||||||
|
$userid++;
|
||||||
|
$i++;
|
||||||
|
|
||||||
if($i > 22) {
|
if ($i > 22) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$startx = 2.5;
|
$startx = 2.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rightlistQuad = new Quad();
|
if ($i > 22) {
|
||||||
$frame->add($rightlistQuad);
|
$i = 0;
|
||||||
$rightlistQuad->setSize((($width/2)-5), ($height-18));
|
$startx = 2.5;
|
||||||
$rightlistQuad->setX(36);
|
}
|
||||||
$rightlistQuad->setY($height / 2 - 46);
|
}
|
||||||
$rightlistQuad->setStyles($quadStyle, $quadSubstyle);
|
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'TSViewer');
|
$rightlistQuad = new Quad();
|
||||||
}
|
$frame->add($rightlistQuad);
|
||||||
|
$rightlistQuad->setSize((($width / 2) - 5), ($height - 18));
|
||||||
|
$rightlistQuad->setX(36);
|
||||||
|
$rightlistQuad->setY($height / 2 - 46);
|
||||||
|
$rightlistQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
/**
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'TSViewer');
|
||||||
* TeamSpeak related functions
|
}
|
||||||
*
|
|
||||||
* The functions are based upon tsstatus.php from http://tsstatus.sebastien.me/
|
|
||||||
* and were optimized by SilentStorm.
|
|
||||||
*
|
|
||||||
* Functions originally from the TeamSpeakInfo plugin made by undef.de for XAseco(2) and MPAseco.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function ts3_queryServer() {
|
/**
|
||||||
if(time() >= $this->refreshTime) {
|
* TeamSpeak related functions
|
||||||
$this->refreshTime = (time()+$this->refreshInterval);
|
* The functions are based upon tsstatus.php from http://tsstatus.sebastien.me/
|
||||||
|
* and were optimized by SilentStorm.
|
||||||
|
* Functions originally from the TeamSpeakInfo plugin made by undef.de for XAseco(2) and MPAseco.
|
||||||
|
*/
|
||||||
|
|
||||||
$queryhost = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYHOST);
|
public function ts3_queryServer() {
|
||||||
$host = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST);
|
if (time() >= $this->refreshTime) {
|
||||||
|
$this->refreshTime = (time() + $this->refreshInterval);
|
||||||
|
|
||||||
$host = ($queryhost != '') ? $queryhost : $host;
|
$queryhost = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYHOST);
|
||||||
|
$host = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST);
|
||||||
|
|
||||||
$socket = fsockopen($host, $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYPORT), $errno, $errstr, 2);
|
$host = ($queryhost != '') ? $queryhost : $host;
|
||||||
if($socket) {
|
|
||||||
socket_set_timeout($socket, 2);
|
|
||||||
$is_ts3 = trim(fgets($socket)) == 'TS3';
|
|
||||||
if(!$is_ts3) {
|
|
||||||
trigger_error('[TeamSpeakPlugin] Server at "'. $host .'" is not a Teamspeak3-Server or you have setup a bad query-port!', E_USER_WARNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
$queryuser = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYUSER);
|
$socket = fsockopen($host, $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYPORT), $errno, $errstr, 2);
|
||||||
$querypass = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYPASS);
|
if ($socket) {
|
||||||
if(($queryuser != '') && !is_numeric($queryuser) && $queryuser != false && ($querypass != '') && !is_numeric($querypass) && $querypass != false) {
|
socket_set_timeout($socket, 2);
|
||||||
$ret = $this->ts3_sendCommand($socket, 'login client_login_name='. $this->ts3_escape($queryuser) .' client_login_password='. $this->ts3_escape($querypass));
|
$is_ts3 = trim(fgets($socket)) == 'TS3';
|
||||||
if(stripos($ret, "error id=0") === false) {
|
if (!$is_ts3) {
|
||||||
trigger_error("[TeamSpeakPlugin] Failed to authenticate with TS3 Server! Make sure you put the correct username & password in teamspeak.xml", E_USER_WARNING);
|
trigger_error('[TeamSpeakPlugin] Server at "' . $host . '" is not a Teamspeak3-Server or you have setup a bad query-port!', E_USER_WARNING);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = '';
|
$queryuser = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYUSER);
|
||||||
$response .= $this->ts3_sendCommand($socket, 'use sid='.$this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SID));
|
$querypass = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYPASS);
|
||||||
$this->ts3_sendCommand($socket, 'clientupdate client_nickname=' . $this->ts3_escape('ManiaControl Viewer'));
|
if (($queryuser != '') && !is_numeric($queryuser) && $queryuser != false && ($querypass != '') && !is_numeric($querypass) && $querypass != false) {
|
||||||
$response .= $this->ts3_sendCommand($socket, 'serverinfo');
|
$ret = $this->ts3_sendCommand($socket, 'login client_login_name=' . $this->ts3_escape($queryuser) . ' client_login_password=' . $this->ts3_escape($querypass));
|
||||||
$response .= $this->ts3_sendCommand($socket, 'channellist -topic -flags -voice -limits');
|
if (stripos($ret, "error id=0") === false) {
|
||||||
$response .= $this->ts3_sendCommand($socket, 'clientlist -uid -away -voice -groups');
|
trigger_error("[TeamSpeakPlugin] Failed to authenticate with TS3 Server! Make sure you put the correct username & password in teamspeak.xml", E_USER_WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fputs($socket, "quit\n");
|
$response = '';
|
||||||
fclose($socket);
|
$response .= $this->ts3_sendCommand($socket, 'use sid=' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SID));
|
||||||
|
$this->ts3_sendCommand($socket, 'clientupdate client_nickname=' . $this->ts3_escape('ManiaControl Viewer'));
|
||||||
|
$response .= $this->ts3_sendCommand($socket, 'serverinfo');
|
||||||
|
$response .= $this->ts3_sendCommand($socket, 'channellist -topic -flags -voice -limits');
|
||||||
|
$response .= $this->ts3_sendCommand($socket, 'clientlist -uid -away -voice -groups');
|
||||||
|
|
||||||
$lines = explode("error id=0 msg=ok\n\r", $response);
|
fputs($socket, "quit\n");
|
||||||
if(count($lines) == 5) {
|
fclose($socket);
|
||||||
$serverdata = $this->ts3_parseLine($lines[1]);
|
|
||||||
$this->serverData['server'] = $serverdata[0];
|
|
||||||
$this->serverData['channels'] = $this->ts3_parseLine($lines[2]);
|
|
||||||
|
|
||||||
$users = $this->ts3_parseLine($lines[3]);
|
$lines = explode("error id=0 msg=ok\n\r", $response);
|
||||||
$this->serverData['users'] = array(); // reset userslist
|
if (count($lines) == 5) {
|
||||||
foreach($users as $user) {
|
$serverdata = $this->ts3_parseLine($lines[1]);
|
||||||
if($user['client_nickname'] != 'ManiaControl Viewer') {
|
$this->serverData['server'] = $serverdata[0];
|
||||||
$this->serverData['users'][] = $user;
|
$this->serverData['channels'] = $this->ts3_parseLine($lines[2]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subtract reserved slots
|
$users = $this->ts3_parseLine($lines[3]);
|
||||||
$this->serverData['server']['virtualserver_maxclients'] -= $this->serverData['server']['virtualserver_reserved_slots'];
|
$this->serverData['users'] = array(); // reset userslist
|
||||||
|
foreach($users as $user) {
|
||||||
|
if ($user['client_nickname'] != 'ManiaControl Viewer') {
|
||||||
|
$this->serverData['users'][] = $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make ping value int
|
// Subtract reserved slots
|
||||||
$this->serverData['server']['virtualserver_total_ping'] = intval($this->serverData['server']['virtualserver_total_ping']);
|
$this->serverData['server']['virtualserver_maxclients'] -= $this->serverData['server']['virtualserver_reserved_slots'];
|
||||||
|
|
||||||
// Format the Date of server startup
|
// Make ping value int
|
||||||
$this->serverData['server']['virtualserver_uptime'] = date('Y-m-d H:i:s', (time() - $this->serverData['server']['virtualserver_uptime']) );
|
$this->serverData['server']['virtualserver_total_ping'] = intval($this->serverData['server']['virtualserver_total_ping']);
|
||||||
|
|
||||||
// Always subtract all Query Clients
|
// Format the Date of server startup
|
||||||
$this->serverData['server']['virtualserver_clientsonline'] -= $this->serverData['server']['virtualserver_queryclientsonline'];
|
$this->serverData['server']['virtualserver_uptime'] = date('Y-m-d H:i:s', (time() - $this->serverData['server']['virtualserver_uptime']));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trigger_error("[TeamSpeakPlugin] Failed to connect with TS3 server; socket error: ". $errstr ." [". $errno ."]", E_USER_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Always subtract all Query Clients
|
||||||
* TS Function to send a command to the TeamSpeak server.
|
$this->serverData['server']['virtualserver_clientsonline'] -= $this->serverData['server']['virtualserver_queryclientsonline'];
|
||||||
* @param $socket
|
}
|
||||||
* @param $cmd
|
} else {
|
||||||
* @return string
|
trigger_error("[TeamSpeakPlugin] Failed to connect with TS3 server; socket error: " . $errstr . " [" . $errno . "]", E_USER_WARNING);
|
||||||
*/
|
}
|
||||||
private function ts3_sendCommand ($socket, $cmd) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fputs($socket, "$cmd\n");
|
/**
|
||||||
|
* TS Function to send a command to the TeamSpeak server.
|
||||||
|
*
|
||||||
|
* @param $socket
|
||||||
|
* @param $cmd
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function ts3_sendCommand($socket, $cmd) {
|
||||||
|
|
||||||
$response = '';
|
fputs($socket, "$cmd\n");
|
||||||
/*while(strpos($response, 'error id=') === false) {
|
|
||||||
$response .= fread($socket, 8096);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*while (!feof($socket)) {
|
$response = '';
|
||||||
$response .= fread($socket, 8192);
|
/*while(strpos($response, 'error id=') === false) {
|
||||||
}*/
|
$response .= fread($socket, 8096);
|
||||||
|
}*/
|
||||||
|
|
||||||
$info = array('timed_out' => false);
|
/*while (!feof($socket)) {
|
||||||
while (!feof($socket) && !$info['timed_out'] && strpos($response, 'error id=') === false) {
|
$response .= fread($socket, 8192);
|
||||||
$response .= fread($socket, 1024);
|
}*/
|
||||||
$info = stream_get_meta_data($socket);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $response;
|
$info = array('timed_out' => false);
|
||||||
}
|
while(!feof($socket) && !$info['timed_out'] && strpos($response, 'error id=') === false) {
|
||||||
|
$response .= fread($socket, 1024);
|
||||||
|
$info = stream_get_meta_data($socket);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return $response;
|
||||||
* TS Function used to parse lines in the serverresponse.
|
}
|
||||||
* @param $rawLine
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function ts3_parseLine ($rawLine) {
|
|
||||||
|
|
||||||
$datas = array();
|
/**
|
||||||
$rawItems = explode('|', $rawLine);
|
* TS Function used to parse lines in the serverresponse.
|
||||||
|
*
|
||||||
|
* @param $rawLine
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function ts3_parseLine($rawLine) {
|
||||||
|
|
||||||
foreach($rawItems as &$rawItem) {
|
$datas = array();
|
||||||
$rawDatas = explode(' ', $rawItem);
|
$rawItems = explode('|', $rawLine);
|
||||||
$tempDatas = array();
|
|
||||||
foreach($rawDatas as &$rawData) {
|
|
||||||
$ar = explode("=", $rawData, 2);
|
|
||||||
$tempDatas[$ar[0]] = isset($ar[1]) ? $this->ts3_unescape($ar[1]) : '';
|
|
||||||
}
|
|
||||||
$datas[] = $tempDatas;
|
|
||||||
}
|
|
||||||
unset($rawItem, $rawData);
|
|
||||||
|
|
||||||
return $datas;
|
foreach($rawItems as &$rawItem) {
|
||||||
}
|
$rawDatas = explode(' ', $rawItem);
|
||||||
|
$tempDatas = array();
|
||||||
|
foreach($rawDatas as &$rawData) {
|
||||||
|
$ar = explode("=", $rawData, 2);
|
||||||
|
$tempDatas[$ar[0]] = isset($ar[1]) ? $this->ts3_unescape($ar[1]) : '';
|
||||||
|
}
|
||||||
|
$datas[] = $tempDatas;
|
||||||
|
}
|
||||||
|
unset($rawItem, $rawData);
|
||||||
|
|
||||||
/**
|
return $datas;
|
||||||
* TS Function used to escape characters in channelnames.
|
}
|
||||||
*
|
|
||||||
* @param $str
|
/**
|
||||||
* @return mixed
|
* TS Function used to escape characters in channelnames.
|
||||||
*/
|
*
|
||||||
private function ts3_escape ($str) {
|
* @param $str
|
||||||
return str_replace(array(chr(92), chr(47), chr(32), chr(124), chr(7), chr(8), chr(12), chr(10), chr(3), chr(9), chr(11)), array('\\\\', "\/", "\s", "\p", "\a", "\b", "\f", "\n", "\r", "\t", "\v"), $str);
|
* @return mixed
|
||||||
}
|
*/
|
||||||
|
private function ts3_escape($str) {
|
||||||
|
return str_replace(array(chr(92), chr(47), chr(32), chr(124), chr(7), chr(8), chr(12), chr(10), chr(3), chr(9), chr(11)), array('\\\\', "\/", "\s", "\p", "\a", "\b", "\f", "\n", "\r", "\t", "\v"), $str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TS Function used to unescape characters in channelnames.
|
||||||
|
*
|
||||||
|
* @param $str
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function ts3_unescape($str) {
|
||||||
|
return str_replace(array('\\\\', "\/", "\s", "\p", "\a", "\b", "\f", "\n", "\r", "\t", "\v"), array(chr(92), chr(47), chr(32), chr(124), chr(7), chr(8), chr(12), chr(10), chr(3), chr(9), chr(11)), $str);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TS Function used to unescape characters in channelnames.
|
|
||||||
*
|
|
||||||
* @param $str
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private function ts3_unescape ($str) {
|
|
||||||
return str_replace(array('\\\\', "\/", "\s", "\p", "\a", "\b", "\f", "\n", "\r", "\t", "\v"), array(chr(92), chr(47), chr(32), chr(124), chr(7), chr(8), chr(12), chr(10), chr(3), chr(9), chr(11)), $str);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -72,6 +72,15 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
|
Loading…
Reference in New Issue
Block a user