Improved PHPDoc, Type Hints & Parameter Names
This commit is contained in:
parent
3e69e03292
commit
2a705e05d9
@ -197,15 +197,18 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Get a List of all Admins
|
* Get a List of all Admins
|
||||||
*
|
*
|
||||||
* @param $authLevel
|
* @param int $authLevel
|
||||||
* @return array null
|
* @return array null
|
||||||
*/
|
*/
|
||||||
public function getAdmins($authLevel = -1) {
|
public function getAdmins($authLevel = null) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
if ($authLevel < 0) {
|
if ($authLevel === null) {
|
||||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` > 0 ORDER BY `authLevel` DESC;";
|
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "`
|
||||||
|
WHERE `authLevel` > 0
|
||||||
|
ORDER BY `authLevel` DESC;";
|
||||||
} else {
|
} else {
|
||||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` = " . $authLevel . ";";
|
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "`
|
||||||
|
WHERE `authLevel` = {$authLevel};";
|
||||||
}
|
}
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -289,7 +292,7 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the Player has enough Rights
|
* Check whether the Player has enough Rights
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int|Setting $neededAuthLevel
|
* @param int|Setting $neededAuthLevel
|
||||||
@ -303,10 +306,10 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a Minimum Right Level needed for an action
|
* Define a Minimum Right Level needed for an Action
|
||||||
*
|
*
|
||||||
* @param $rightName
|
* @param string $rightName
|
||||||
* @param $authLevelNeeded
|
* @param int $authLevelNeeded
|
||||||
*/
|
*/
|
||||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||||
$this->maniaControl->settingManager->initSetting($this, $rightName, $authLevelNeeded);
|
$this->maniaControl->settingManager->initSetting($this, $rightName, $authLevelNeeded);
|
||||||
|
@ -64,22 +64,15 @@ class BillManager implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Send Planets from the server to a Player
|
* Send Planets from the server to a Player
|
||||||
*
|
*
|
||||||
* @param $function
|
* @param callable $function
|
||||||
* @param $receiverLogin
|
* @param string $receiverLogin
|
||||||
* @param $amount
|
* @param int $amount
|
||||||
* @param $message
|
* @param string $message
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function sendPlanets($function, $receiverLogin, $amount, $message) {
|
public function sendPlanets(callable $function, $receiverLogin, $amount, $message) {
|
||||||
if (!is_callable($function)) {
|
|
||||||
trigger_error("Function is not callable");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bill = $this->maniaControl->client->pay($receiverLogin, $amount, $message);
|
$bill = $this->maniaControl->client->pay($receiverLogin, $amount, $message);
|
||||||
|
|
||||||
$this->openBills[$bill] = new BillData($function, $receiverLogin, $amount, true);
|
$this->openBills[$bill] = new BillData($function, $receiverLogin, $amount, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +124,12 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the commands for the HelpAll ManiaLink.
|
* Prepare the commands for the HelpAll ManiaLink.
|
||||||
*
|
*
|
||||||
* @param $commands
|
* @param array $commands
|
||||||
* @param $player
|
* @param mixed $player
|
||||||
*/
|
*/
|
||||||
private function prepareHelpAll($commands, $player) {
|
private function prepareHelpAll(array $commands, $player) {
|
||||||
$showCommands = array();
|
$showCommands = array();
|
||||||
$registeredMethods = array();
|
$registeredMethods = array();
|
||||||
foreach (array_reverse($commands) as $command) {
|
foreach (array_reverse($commands) as $command) {
|
||||||
@ -157,10 +157,10 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Shows the HelpAll list to the player.
|
* Shows the HelpAll list to the player.
|
||||||
*
|
*
|
||||||
* @param $commands
|
* @param array $commands
|
||||||
* @param $player
|
* @param mixed $player
|
||||||
*/
|
*/
|
||||||
private function showHelpAllList($commands, $player) {
|
private function showHelpAllList(array $commands, $player) {
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
|
|
||||||
|
@ -340,14 +340,14 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
|||||||
/**
|
/**
|
||||||
* Gets the Menu Id
|
* Gets the Menu Id
|
||||||
*
|
*
|
||||||
* @param $name
|
* @param string $title
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getMenuId($name) {
|
public function getMenuId($title) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($this->menus as $menu) {
|
foreach ($this->menus as $menu) {
|
||||||
/** @var ConfiguratorMenu $menu */
|
/** @var ConfiguratorMenu $menu */
|
||||||
if ($menu == $name || $menu->getTitle() == $name) {
|
if ($menu === $title || $menu->getTitle() === $title) {
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
|
@ -164,11 +164,9 @@ class ManiaControl implements CommandListener, TimerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks connection every xxx Minutes
|
* Check Connection
|
||||||
*
|
|
||||||
* @param $time
|
|
||||||
*/
|
*/
|
||||||
public function checkConnection($time) {
|
public function checkConnection() {
|
||||||
if ($this->client->getIdleTime() > 180) {
|
if ($this->client->getIdleTime() > 180) {
|
||||||
$this->client->getServerName();
|
$this->client->getServerName();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class ManiaExchangeManager {
|
|||||||
/**
|
/**
|
||||||
* Unset Map by Mx Id
|
* Unset Map by Mx Id
|
||||||
*
|
*
|
||||||
* @param $mxId
|
* @param int $mxId
|
||||||
*/
|
*/
|
||||||
public function unsetMap($mxId) {
|
public function unsetMap($mxId) {
|
||||||
if (isset($this->mxIdUidVector[$mxId])) {
|
if (isset($this->mxIdUidVector[$mxId])) {
|
||||||
@ -142,7 +142,7 @@ class ManiaExchangeManager {
|
|||||||
/**
|
/**
|
||||||
* Get the Whole MapList from MX by Mixed Uid and Id String fetch
|
* Get the Whole MapList from MX by Mixed Uid and Id String fetch
|
||||||
*
|
*
|
||||||
* @param $string
|
* @param string $string
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function getMaplistByMixedUidIdString($string) {
|
public function getMaplistByMixedUidIdString($string) {
|
||||||
@ -187,11 +187,11 @@ class ManiaExchangeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store Map Info from MX and store the mxid in the database and the mx info in the map object
|
* Store MX Map Info in the Database and the MX Info in the Map Object
|
||||||
*
|
*
|
||||||
* @param $mxMapInfos
|
* @param array $mxMapInfos
|
||||||
*/
|
*/
|
||||||
public function updateMapObjectsWithManiaExchangeIds($mxMapInfos) {
|
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
// Save map data
|
// Save map data
|
||||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||||
@ -231,11 +231,11 @@ class ManiaExchangeManager {
|
|||||||
/**
|
/**
|
||||||
* Get Map Info Asynchronously
|
* Get Map Info Asynchronously
|
||||||
*
|
*
|
||||||
* @param $id
|
* @param int $id
|
||||||
* @param $function
|
* @param callable $function
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getMapInfo($id, $function) {
|
public function getMapInfo($id, callable $function) {
|
||||||
// Get Title Prefix
|
// Get Title Prefix
|
||||||
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
||||||
|
|
||||||
@ -344,9 +344,9 @@ class ManiaExchangeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Current Environment by String
|
* Get the Current Environment by String
|
||||||
*
|
*
|
||||||
* @param $env
|
* @param string $env
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function getEnvironment($env) {
|
private function getEnvironment($env) {
|
||||||
|
@ -52,11 +52,9 @@ class CustomUIManager implements CallbackListener, TimerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 1Second
|
* Handle 1 Second Callback
|
||||||
*
|
|
||||||
* @param $time
|
|
||||||
*/
|
*/
|
||||||
public function handle1Second($time) {
|
public function handle1Second() {
|
||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,9 @@ class IconManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an Icon by its name
|
* Get an Icon by its Name
|
||||||
*
|
*
|
||||||
* @param $iconName
|
* @param string $iconName
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIcon($iconName) {
|
public function getIcon($iconName) {
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Maps;
|
namespace ManiaControl\Maps;
|
||||||
|
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||||
|
use ManiaControl\Utils\Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map Model Class
|
* Map Model Class
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl\Maps;
|
||||||
|
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map Actions Class
|
* Map Actions Class
|
||||||
*
|
*
|
||||||
@ -6,12 +12,6 @@
|
|||||||
* @copyright 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
namespace ManiaControl\Maps;
|
|
||||||
|
|
||||||
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
|
||||||
|
|
||||||
class MapActions {
|
class MapActions {
|
||||||
/*
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
|
@ -359,10 +359,10 @@ class MapManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns map By UID
|
* Get Map by UID
|
||||||
*
|
*
|
||||||
* @param $uid
|
* @param string $uid
|
||||||
* @return Map array
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public function getMapByUid($uid) {
|
public function getMapByUid($uid) {
|
||||||
if (!isset($this->maps[$uid])) {
|
if (!isset($this->maps[$uid])) {
|
||||||
@ -417,7 +417,7 @@ class MapManager implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Initializes a Map
|
* Initializes a Map
|
||||||
*
|
*
|
||||||
* @param $rpcMap
|
* @param mixed $rpcMap
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public function initializeMap($rpcMap) {
|
public function initializeMap($rpcMap) {
|
||||||
|
@ -7,9 +7,9 @@ use ManiaControl\Callbacks\CallbackListener;
|
|||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Utils\Formatter;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,13 +45,6 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
private $buffer = array();
|
private $buffer = array();
|
||||||
private $nextNoQueue = false;
|
private $nextNoQueue = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Don't queue on the next MapChange
|
|
||||||
*/
|
|
||||||
public function dontQueueNextMapChange() {
|
|
||||||
$this->nextNoQueue = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server MapQueue
|
* Create a new server MapQueue
|
||||||
*
|
*
|
||||||
@ -80,6 +73,13 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
$this->maniaControl->commandManager->registerCommandListener(array('jb', 'jukebox', 'mapqueue'), $this, 'command_MapQueue', false, 'Shows current maps in Map-Queue.');
|
$this->maniaControl->commandManager->registerCommandListener(array('jb', 'jukebox', 'mapqueue'), $this, 'command_MapQueue', false, 'Shows current maps in Map-Queue.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't queue on the next MapChange
|
||||||
|
*/
|
||||||
|
public function dontQueueNextMapChange() {
|
||||||
|
$this->nextNoQueue = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds current map to buffer on startup
|
* Adds current map to buffer on startup
|
||||||
*/
|
*/
|
||||||
@ -201,7 +201,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
* Adds map as first map in queue (for /replay)
|
* Adds map as first map in queue (for /replay)
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param Map $map
|
* @param Map $map
|
||||||
*/
|
*/
|
||||||
public function addFirstMapToMapQueue(Player $player, Map $map) {
|
public function addFirstMapToMapQueue(Player $player, Map $map) {
|
||||||
if ($map) {
|
if ($map) {
|
||||||
@ -303,7 +303,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
*/
|
*/
|
||||||
public function endMap(Map $map = null) {
|
public function endMap(Map $map = null) {
|
||||||
//Don't queue next map (for example on skip to map)
|
//Don't queue next map (for example on skip to map)
|
||||||
if($this->nextNoQueue){
|
if ($this->nextNoQueue) {
|
||||||
$this->nextNoQueue = false;
|
$this->nextNoQueue = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
$player = $queuedMap[0];
|
$player = $queuedMap[0];
|
||||||
|
|
||||||
// Check if map is added via replay vote/command
|
// Check if map is added via replay vote/command
|
||||||
if(isset($queuedMap[2]) && $queuedMap[2] === true) {
|
if (isset($queuedMap[2]) && $queuedMap[2] === true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,9 +352,9 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
$this->maniaControl->chat->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
$this->maniaControl->chat->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
||||||
|
|
||||||
try{
|
try {
|
||||||
$this->maniaControl->client->setNextMapIdent($map->uid);
|
$this->maniaControl->client->setNextMapIdent($map->uid);
|
||||||
}catch (NextMapException $e){
|
} catch (NextMapException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,9 +415,9 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Queuer of a Map
|
* Return the Queuer of a Map
|
||||||
*
|
*
|
||||||
* @param $uid
|
* @param string $uid
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getQueuer($uid) {
|
public function getQueuer($uid) {
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Players;
|
namespace ManiaControl\Players;
|
||||||
|
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Utils\ClassUtil;
|
use ManiaControl\Utils\ClassUtil;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Model Class
|
* Player Model Class
|
||||||
@ -80,6 +80,19 @@ class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Login of the Player
|
||||||
|
*
|
||||||
|
* @param mixed $player
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function parseLogin($player) {
|
||||||
|
if (is_object($player) && property_exists($player, 'login')) {
|
||||||
|
return (string)$player->login;
|
||||||
|
}
|
||||||
|
return (string)$player;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Escaped Nickname
|
* Get the Escaped Nickname
|
||||||
*
|
*
|
||||||
@ -263,7 +276,7 @@ class Player {
|
|||||||
/**
|
/**
|
||||||
* Set the Cache Data for the given Name
|
* Set the Cache Data for the given Name
|
||||||
*
|
*
|
||||||
* @param $object
|
* @param mixed $object
|
||||||
* @param string $cacheName
|
* @param string $cacheName
|
||||||
* @param mixed $data
|
* @param mixed $data
|
||||||
*/
|
*/
|
||||||
@ -273,10 +286,10 @@ class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys a Cache
|
* Destroy a Cache
|
||||||
*
|
*
|
||||||
* @param mixed $object
|
* @param mixed $object
|
||||||
* @param $cacheName
|
* @param string $cacheName
|
||||||
*/
|
*/
|
||||||
public function destroyCache($object, $cacheName) {
|
public function destroyCache($object, $cacheName) {
|
||||||
$className = ClassUtil::getClass($object);
|
$className = ClassUtil::getClass($object);
|
||||||
@ -290,14 +303,13 @@ class Player {
|
|||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Player Data
|
* Gets the Player Data
|
||||||
*
|
*
|
||||||
* @param $object
|
* @param mixed $object
|
||||||
* @param $dataName
|
* @param string $dataName
|
||||||
* @param $serverIndex
|
* @param int $serverIndex
|
||||||
* @return mixed|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getPlayerData($object, $dataName, $serverIndex = -1) {
|
public function getPlayerData($object, $dataName, $serverIndex = -1) {
|
||||||
return $this->maniaControl->playerManager->playerDataManager->getPlayerData($object, $dataName, $this, $serverIndex);
|
return $this->maniaControl->playerManager->playerDataManager->getPlayerData($object, $dataName, $this, $serverIndex);
|
||||||
@ -306,10 +318,10 @@ class Player {
|
|||||||
/**
|
/**
|
||||||
* Sets the Player Data
|
* Sets the Player Data
|
||||||
*
|
*
|
||||||
* @param $object
|
* @param mixed $object
|
||||||
* @param $dataName
|
* @param string $dataName
|
||||||
* @param $value
|
* @param mixed $value
|
||||||
* @param $serverIndex
|
* @param int $serverIndex
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setPlayerData($object, $dataName, $value, $serverIndex = -1) {
|
public function setPlayerData($object, $dataName, $value, $serverIndex = -1) {
|
||||||
@ -324,7 +336,7 @@ class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump the Players Cache
|
* Var_Dump the Players Cache
|
||||||
*/
|
*/
|
||||||
public function dumpCache() {
|
public function dumpCache() {
|
||||||
var_dump($this->cache);
|
var_dump($this->cache);
|
||||||
|
@ -129,10 +129,10 @@ class PlayerDataManager {
|
|||||||
/**
|
/**
|
||||||
* Defines the Player-Data MetaData
|
* Defines the Player-Data MetaData
|
||||||
*
|
*
|
||||||
* @param $object
|
* @param mixed $object
|
||||||
* @param $dataName
|
* @param string $dataName
|
||||||
* @param $default
|
* @param mixed $default
|
||||||
* @param $dataDescription (optional)
|
* @param string $dataDescription (optional)
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function defineMetaData($object, $dataName, $default, $dataDescription = '') {
|
public function defineMetaData($object, $dataName, $default, $dataDescription = '') {
|
||||||
@ -198,11 +198,11 @@ class PlayerDataManager {
|
|||||||
/**
|
/**
|
||||||
* Gets the Player Data
|
* Gets the Player Data
|
||||||
*
|
*
|
||||||
* @param mixed $object
|
* @param mixed $object
|
||||||
* @param string $dataName
|
* @param string $dataName
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int $serverIndex
|
* @param int $serverIndex
|
||||||
* @return mixed|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getPlayerData($object, $dataName, Player $player, $serverIndex = -1) {
|
public function getPlayerData($object, $dataName, Player $player, $serverIndex = -1) {
|
||||||
$className = ClassUtil::getClass($object);
|
$className = ClassUtil::getClass($object);
|
||||||
@ -254,11 +254,11 @@ class PlayerDataManager {
|
|||||||
/**
|
/**
|
||||||
* Set a PlayerData to a specific defined statMetaData
|
* Set a PlayerData to a specific defined statMetaData
|
||||||
*
|
*
|
||||||
* @param mixed $object
|
* @param mixed $object
|
||||||
* @param string $dataName
|
* @param string $dataName
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param int $serverIndex (let it empty if its global)
|
* @param int $serverIndex (empty if it's global)
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setPlayerData($object, $dataName, Player $player, $value, $serverIndex = -1) {
|
public function setPlayerData($object, $dataName, Player $player, $value, $serverIndex = -1) {
|
||||||
|
@ -19,8 +19,8 @@ class PluginManager {
|
|||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const TABLE_PLUGINS = 'mc_plugins';
|
const TABLE_PLUGINS = 'mc_plugins';
|
||||||
const CB_PLUGIN_LOADED = 'PluginManager.PluginLoaded';
|
const CB_PLUGIN_LOADED = 'PluginManager.PluginLoaded';
|
||||||
const CB_PLUGIN_UNLOADED = 'PluginManager.PluginUnloaded';
|
const CB_PLUGIN_UNLOADED = 'PluginManager.PluginUnloaded';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -400,9 +400,9 @@ class PluginManager {
|
|||||||
/**
|
/**
|
||||||
* Fetch the Plugins List from the ManiaControl Website
|
* Fetch the Plugins List from the ManiaControl Website
|
||||||
*
|
*
|
||||||
* @param $function
|
* @param callable $function
|
||||||
*/
|
*/
|
||||||
public function fetchPluginList($function) {
|
public function fetchPluginList(callable $function) {
|
||||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||||
|
|
||||||
$this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use (&$function) {
|
$this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||||
|
@ -71,7 +71,7 @@ class RankingManager implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Update Game Rankings (never call this Method)
|
* Update Game Rankings (never call this Method)
|
||||||
*
|
*
|
||||||
* @param $data
|
* @param string $data
|
||||||
*/
|
*/
|
||||||
public function updateRankings($data) {
|
public function updateRankings($data) {
|
||||||
if (!is_string($data)) {
|
if (!is_string($data)) {
|
||||||
|
@ -4,8 +4,9 @@ namespace ManiaControl\Server;
|
|||||||
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Utils\CommandLineHelper;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Utils\CommandLineHelper;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,10 +261,11 @@ class Server implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Retrieve Validation Replay for the given Player
|
* Retrieve Validation Replay for the given Player
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param string $login
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getValidationReplay($login) {
|
public function getValidationReplay($login) {
|
||||||
|
$login = Player::parseLogin($login);
|
||||||
try {
|
try {
|
||||||
$replay = $this->maniaControl->client->getValidationReplay($login);
|
$replay = $this->maniaControl->client->getValidationReplay($login);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -279,7 +281,7 @@ class Server implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Retrieve Ghost Replay for the given Player
|
* Retrieve Ghost Replay for the given Player
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param string $login
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getGhostReplay($login) {
|
public function getGhostReplay($login) {
|
||||||
@ -289,6 +291,7 @@ class Server implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build file name
|
// Build file name
|
||||||
|
$login = Player::parseLogin($login);
|
||||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
$gameMode = $this->getGameMode();
|
$gameMode = $this->getGameMode();
|
||||||
$time = time();
|
$time = time();
|
||||||
|
@ -210,12 +210,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check stuff each 5 seconds
|
* Check Stuff each 5 Seconds
|
||||||
*
|
|
||||||
* @param $timer
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function each5Seconds($timer) {
|
public function each5Seconds() {
|
||||||
// Empty shutdown
|
// Empty shutdown
|
||||||
if ($this->serverShutdownEmpty) {
|
if ($this->serverShutdownEmpty) {
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
|
@ -313,7 +313,7 @@ class StatisticManager {
|
|||||||
/**
|
/**
|
||||||
* Return the Stat Id
|
* Return the Stat Id
|
||||||
*
|
*
|
||||||
* @param $statName
|
* @param string $statName
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function getStatId($statName) {
|
private function getStatId($statName) {
|
||||||
|
@ -142,14 +142,14 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
|||||||
* Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for
|
* Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for
|
||||||
* (last joined)
|
* (last joined)
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param mixed $login
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function getTarget($login) {
|
private function getTarget($login) {
|
||||||
/** @var Player $player */
|
/** @var Player $player */
|
||||||
$player = null;
|
$player = null;
|
||||||
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
|
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||||
if ($login == $player->login || $login == $player->pid || $login == $player->nickname) {
|
if ($login == $player && $login == $player->login || $login == $player->pid || $login == $player->nickname) {
|
||||||
return $player->nickname;
|
return $player->nickname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,8 +486,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
/**
|
/**
|
||||||
* Handle Standard Votes
|
* Handle Standard Votes
|
||||||
*
|
*
|
||||||
* @param $voteName
|
* @param string $voteName
|
||||||
* @param $voteResult
|
* @param float $voteResult
|
||||||
*/
|
*/
|
||||||
public function handleVoteFinished($voteName, $voteResult) {
|
public function handleVoteFinished($voteName, $voteResult) {
|
||||||
if ($voteResult >= $this->currentVote->neededRatio) {
|
if ($voteResult >= $this->currentVote->neededRatio) {
|
||||||
@ -563,9 +563,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undefines a Vote
|
* Undefine a Vote
|
||||||
*
|
*
|
||||||
* @param $voteIndex
|
* @param int $voteIndex
|
||||||
*/
|
*/
|
||||||
public function undefineVote($voteIndex) {
|
public function undefineVote($voteIndex) {
|
||||||
unset($this->voteCommands[$voteIndex]);
|
unset($this->voteCommands[$voteIndex]);
|
||||||
@ -600,11 +600,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle ManiaControl 1 Second callback
|
* Handle ManiaControl 1 Second Callback
|
||||||
*
|
|
||||||
* @param $time
|
|
||||||
*/
|
*/
|
||||||
public function handle1Second($time) {
|
public function handle1Second() {
|
||||||
if (!isset($this->currentVote)) {
|
if (!isset($this->currentVote)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -774,10 +772,10 @@ class VoteCommand {
|
|||||||
/**
|
/**
|
||||||
* Construct a new Vote Command
|
* Construct a new Vote Command
|
||||||
*
|
*
|
||||||
* @param $index
|
* @param int $index
|
||||||
* @param $name
|
* @param string $name
|
||||||
* @param $idBased
|
* @param bool $idBased
|
||||||
* @param $neededRatio
|
* @param float $neededRatio
|
||||||
*/
|
*/
|
||||||
public function __construct($index, $name, $idBased, $neededRatio) {
|
public function __construct($index, $name, $idBased, $neededRatio) {
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace MCTeam\Dedimania;
|
namespace MCTeam\Dedimania;
|
||||||
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Players\Player;
|
||||||
use Maniaplanet\DedicatedServer\Structures\Version;
|
use Maniaplanet\DedicatedServer\Structures\Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +53,11 @@ class DedimaniaData {
|
|||||||
$this->serverBuild = $serverVersion->build;
|
$this->serverBuild = $serverVersion->build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the Data Array
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
$array = array();
|
$array = array();
|
||||||
foreach (get_object_vars($this) as $key => $value) {
|
foreach (get_object_vars($this) as $key => $value) {
|
||||||
@ -63,6 +69,11 @@ class DedimaniaData {
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Number of Records
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function getRecordCount() {
|
public function getRecordCount() {
|
||||||
return count($this->records);
|
return count($this->records);
|
||||||
}
|
}
|
||||||
@ -70,10 +81,11 @@ class DedimaniaData {
|
|||||||
/**
|
/**
|
||||||
* Get Max Rank for a certain Player
|
* Get Max Rank for a certain Player
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param mixed $login
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getPlayerMaxRank($login) {
|
public function getPlayerMaxRank($login) {
|
||||||
|
$login = Player::parseLogin($login);
|
||||||
$maxRank = $this->serverMaxRank;
|
$maxRank = $this->serverMaxRank;
|
||||||
foreach ($this->players as $player) {
|
foreach ($this->players as $player) {
|
||||||
/** @var DedimaniaPlayer $player */
|
/** @var DedimaniaPlayer $player */
|
||||||
|
@ -14,12 +14,12 @@ use ManiaControl\Callbacks\CallbackManager;
|
|||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Utils\Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Dedimania Plugin
|
* ManiaControl Dedimania Plugin
|
||||||
@ -226,11 +226,11 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
/**
|
/**
|
||||||
* Handle xml rpc fault
|
* Handle xml rpc fault
|
||||||
*
|
*
|
||||||
* @param $fault
|
* @param array $fault
|
||||||
* @param $method
|
* @param string $method
|
||||||
*/
|
*/
|
||||||
private function handleXmlRpcFault($fault, $method) {
|
private function handleXmlRpcFault(array $fault, $method) {
|
||||||
trigger_error('XmlRpc Fault on ' . $method . ': ' . $fault['faultString'] . ' (' . $fault['faultCode'] . ')');
|
trigger_error("XmlRpc Fault on '{$method}': '{$fault['faultString']} ({$fault['faultCode']})!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -505,11 +505,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the session is alive every minute
|
* Handle 1 Minute Callback
|
||||||
*
|
|
||||||
* @param null $callback
|
|
||||||
*/
|
*/
|
||||||
public function handleEveryMinute($callback = null) {
|
public function handleEveryMinute() {
|
||||||
if (!$this->init) {
|
if (!$this->init) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -633,21 +631,17 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle Begin Map
|
* Handle Begin Map Callback
|
||||||
*
|
|
||||||
* @param $callback
|
|
||||||
*/
|
*/
|
||||||
public function handleBeginMap($callback) {
|
public function handleBeginMap() {
|
||||||
unset($this->dedimaniaData->records);
|
unset($this->dedimaniaData->records);
|
||||||
$this->fetchDedimaniaRecords(true);
|
$this->fetchDedimaniaRecords(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle EndMap callback
|
* Handle EndMap Callback
|
||||||
*
|
|
||||||
* @param $callback
|
|
||||||
*/
|
*/
|
||||||
public function handleMapEnd($callback) {
|
public function handleMapEnd() {
|
||||||
if (!$this->dedimaniaData || !$this->dedimaniaData->records) {
|
if (!$this->dedimaniaData || !$this->dedimaniaData->records) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -714,11 +708,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the Playerlist every 3 Minutes
|
* Update the PlayerList every 3 Minutes
|
||||||
*
|
|
||||||
* @param $callback
|
|
||||||
*/
|
*/
|
||||||
public function updatePlayerList($callback) {
|
public function updatePlayerList() {
|
||||||
$serverInfo = $this->getServerInfo();
|
$serverInfo = $this->getServerInfo();
|
||||||
$playerList = $this->getPlayerList();
|
$playerList = $this->getPlayerList();
|
||||||
$votesInfo = $this->getVotesInfo();
|
$votesInfo = $this->getVotesInfo();
|
||||||
@ -769,11 +761,11 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerCheckpoint callback
|
* Handle PlayerCheckpoint Callback
|
||||||
*
|
*
|
||||||
* @param $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerCheckpoint($callback) {
|
public function handlePlayerCheckpoint(array $callback) {
|
||||||
$data = $callback[1];
|
$data = $callback[1];
|
||||||
$login = $data[1];
|
$login = $data[1];
|
||||||
$time = $data[2];
|
$time = $data[2];
|
||||||
@ -786,11 +778,11 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player finished callback
|
* Handle Player Finished Callback
|
||||||
*
|
*
|
||||||
* @param $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerFinished($callback) {
|
public function handlePlayerFinished(array $callback) {
|
||||||
//var_dump($callback);
|
//var_dump($callback);
|
||||||
$data = $callback[1];
|
$data = $callback[1];
|
||||||
if ($data[0] <= 0 || $data[2] <= 0) {
|
if ($data[0] <= 0 || $data[2] <= 0) {
|
||||||
|
@ -11,7 +11,6 @@ use ManiaControl\Callbacks\CallbackListener;
|
|||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Utils\ColorUtil;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
@ -20,6 +19,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
use ManiaControl\Plugins\PluginMenu;
|
use ManiaControl\Plugins\PluginMenu;
|
||||||
use ManiaControl\Settings\Setting;
|
use ManiaControl\Settings\Setting;
|
||||||
use ManiaControl\Settings\SettingManager;
|
use ManiaControl\Settings\SettingManager;
|
||||||
|
use ManiaControl\Utils\ColorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Karma Plugin
|
* ManiaControl Karma Plugin
|
||||||
@ -280,7 +280,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Activates the MX-Karma Session
|
* Activates the MX-Karma Session
|
||||||
*
|
*
|
||||||
* @param $mxKarmaCode
|
* @param string $mxKarmaCode
|
||||||
*/
|
*/
|
||||||
private function activateSession($mxKarmaCode) {
|
private function activateSession($mxKarmaCode) {
|
||||||
$hash = $this->buildActivationHash($this->mxKarma['session']->sessionSeed, $mxKarmaCode);
|
$hash = $this->buildActivationHash($this->mxKarma['session']->sessionSeed, $mxKarmaCode);
|
||||||
@ -323,8 +323,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Builds a sha512 activation Hash for the MX-Karma
|
* Builds a sha512 activation Hash for the MX-Karma
|
||||||
*
|
*
|
||||||
* @param $sessionSeed
|
* @param string $sessionSeed
|
||||||
* @param $mxKey
|
* @param string $mxKey
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function buildActivationHash($sessionSeed, $mxKey) {
|
private function buildActivationHash($sessionSeed, $mxKey) {
|
||||||
@ -756,11 +756,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle ManiaControl 1 Second callback
|
* Handle ManiaControl 1 Second Callback
|
||||||
*
|
|
||||||
* @param $time
|
|
||||||
*/
|
*/
|
||||||
public function handle1Second($time) {
|
public function handle1Second() {
|
||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ use ManiaControl\Callbacks\CallbackManager;
|
|||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
@ -24,6 +23,7 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
use ManiaControl\Settings\Setting;
|
use ManiaControl\Settings\Setting;
|
||||||
use ManiaControl\Settings\SettingManager;
|
use ManiaControl\Settings\SettingManager;
|
||||||
|
use ManiaControl\Utils\Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Local Records Plugin
|
* ManiaControl Local Records Plugin
|
||||||
@ -182,11 +182,9 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 1Second callback
|
* Handle 1 Second Callback
|
||||||
*
|
|
||||||
* @param $time
|
|
||||||
*/
|
*/
|
||||||
public function handle1Second($time) {
|
public function handle1Second() {
|
||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -352,12 +350,13 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
/**
|
/**
|
||||||
* Handle PlayerCheckpoint callback
|
* Handle PlayerCheckpoint callback
|
||||||
*
|
*
|
||||||
* @param $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerCheckpoint($callback) {
|
public function handlePlayerCheckpoint(array $callback) {
|
||||||
$data = $callback[1];
|
$data = $callback[1];
|
||||||
$login = $data[1];
|
$login = $data[1];
|
||||||
$time = $data[2];
|
$time = $data[2];
|
||||||
|
// TODO: lap
|
||||||
// $lap = $data[3];
|
// $lap = $data[3];
|
||||||
$cpIndex = $data[4];
|
$cpIndex = $data[4];
|
||||||
if (!isset($this->checkpoints[$login]) || $cpIndex <= 0) {
|
if (!isset($this->checkpoints[$login]) || $cpIndex <= 0) {
|
||||||
|
@ -34,6 +34,8 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
*/
|
*/
|
||||||
const ID = 22;
|
const ID = 22;
|
||||||
const VERSION = 0.12;
|
const VERSION = 0.12;
|
||||||
|
const AUTHOR = 'TheM';
|
||||||
|
const NAME = 'Queue Plugin';
|
||||||
const ML_ID = 'Queue.Widget';
|
const ML_ID = 'Queue.Widget';
|
||||||
const ML_ADDTOQUEUE = 'Queue.Add';
|
const ML_ADDTOQUEUE = 'Queue.Add';
|
||||||
const ML_REMOVEFROMQUEUE = 'Queue.Remove';
|
const ML_REMOVEFROMQUEUE = 'Queue.Remove';
|
||||||
@ -55,65 +57,49 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
private $maxPlayers = 0;
|
private $maxPlayers = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
// TODO: Implement prepare() method.
|
// TODO: Implement prepare() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get plugin id
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public static function getId() {
|
public static function getId() {
|
||||||
return self::ID;
|
return self::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Name
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getName() {
|
||||||
return 'Queue Plugin';
|
return self::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Version
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
*/
|
||||||
public static function getVersion() {
|
public static function getVersion() {
|
||||||
return self::VERSION;
|
return self::VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Author
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getAuthor() {
|
||||||
return 'TheM';
|
return self::AUTHOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Description
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getDescription() {
|
public static function getDescription() {
|
||||||
return 'Plugin offers the known AutoQueue/SpecJam options.';
|
return 'Plugin offers the known AutoQueue/SpecJam options.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
@ -156,7 +142,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
|
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
$maxQueue = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_MAX);
|
$maxQueue = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_MAX);
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
@ -237,7 +223,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload the plugin and its resources
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
foreach ($this->spectators as $spectator) {
|
foreach ($this->spectators as $spectator) {
|
||||||
@ -299,9 +285,9 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function removes a player from the queue.
|
* Remove a Player from the Queue
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param string $login
|
||||||
*/
|
*/
|
||||||
private function removePlayerFromQueue($login) {
|
private function removePlayerFromQueue($login) {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
@ -317,6 +303,9 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
$this->showQueueWidgetSpectators();
|
$this->showQueueWidgetSpectators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the Queue Widgets to Spectators
|
||||||
|
*/
|
||||||
public function showQueueWidgetSpectators() {
|
public function showQueueWidgetSpectators() {
|
||||||
foreach ($this->spectators as $login) {
|
foreach ($this->spectators as $login) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
@ -445,7 +434,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
/**
|
/**
|
||||||
* Function sends (or not depending on setting) chatmessages for the queue.
|
* Function sends (or not depending on setting) chatmessages for the queue.
|
||||||
*
|
*
|
||||||
* @param $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
private function sendChatMessage($message) {
|
private function sendChatMessage($message) {
|
||||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_CHATMESSAGES)) {
|
if ($this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_CHATMESSAGES)) {
|
||||||
@ -526,10 +515,8 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for being of new map to retrieve maximum number of players.
|
* Checks for being of new map to retrieve maximum number of players.
|
||||||
*
|
|
||||||
* @param $currentMap
|
|
||||||
*/
|
*/
|
||||||
public function handleBeginMap($currentMap) {
|
public function handleBeginMap() {
|
||||||
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
|
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ use FML\ManiaLink;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Utils\Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TeamSpeak Info plugin
|
* TeamSpeak Info plugin
|
||||||
@ -70,66 +70,6 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_QUERYPASS, '');
|
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_QUERYPASS, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the plugin
|
|
||||||
*
|
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function load(ManiaControl $maniaControl) {
|
|
||||||
$this->maniaControl = $maniaControl;
|
|
||||||
$this->checkConfig();
|
|
||||||
|
|
||||||
$this->refreshTime = time();
|
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON);
|
|
||||||
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON_MOVER);
|
|
||||||
|
|
||||||
$this->maniaControl->timerManager->registerTimerListening($this, 'ts3_queryServer', 1000);
|
|
||||||
|
|
||||||
$this->addToMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function used to check certain configuration options to check if they can be used.
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
private function checkConfig() {
|
|
||||||
if ($this->maniaControl->settingManager->getSettingValue($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
|
|
||||||
if (!isset($this->serverData['channels']) || count($this->serverData['channels']) == 0) {
|
|
||||||
$error = 'Could not make proper connections with the server!';
|
|
||||||
throw new \Exception($error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function used insert the icon into the menu.
|
|
||||||
*/
|
|
||||||
private function addToMenu() {
|
|
||||||
$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
|
|
||||||
*/
|
|
||||||
public function unload() {
|
|
||||||
$this->serverData = array();
|
|
||||||
|
|
||||||
$this->maniaControl->actionsMenu->removeMenuItem(1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get plugin id
|
* Get plugin id
|
||||||
*
|
*
|
||||||
@ -175,6 +115,215 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
return 'Plugin offers a connection with a TeamSpeak server (via widgets).';
|
return 'Plugin offers a connection with a TeamSpeak server (via widgets).';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the plugin
|
||||||
|
*
|
||||||
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function load(ManiaControl $maniaControl) {
|
||||||
|
$this->maniaControl = $maniaControl;
|
||||||
|
$this->checkConfig();
|
||||||
|
|
||||||
|
$this->refreshTime = time();
|
||||||
|
|
||||||
|
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON);
|
||||||
|
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON_MOVER);
|
||||||
|
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'ts3_queryServer', 1000);
|
||||||
|
|
||||||
|
$this->addToMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function used to check certain configuration options to check if they can be used.
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function checkConfig() {
|
||||||
|
if ($this->maniaControl->settingManager->getSettingValue($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
|
||||||
|
if (!isset($this->serverData['channels']) || count($this->serverData['channels']) == 0) {
|
||||||
|
$error = 'Could not make proper connections with the server!';
|
||||||
|
throw new \Exception($error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
$this->refreshTime = (time() + $this->refreshInterval);
|
||||||
|
|
||||||
|
$queryHost = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYHOST);
|
||||||
|
$host = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERHOST);
|
||||||
|
|
||||||
|
$host = ($queryHost != '') ? $queryHost : $host;
|
||||||
|
$queryPort = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYPORT);
|
||||||
|
|
||||||
|
$socket = fsockopen(@$host, $queryPort, $errno, $errstr, 2);
|
||||||
|
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->getSettingValue($this, self::TEAMSPEAK_QUERYUSER);
|
||||||
|
$querypass = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYPASS);
|
||||||
|
if (($queryuser != '') && !is_numeric($queryuser) && $queryuser != false && ($querypass != '') && !is_numeric($querypass) && $querypass != false) {
|
||||||
|
$ret = $this->ts3_sendCommand($socket, 'login client_login_name=' . $this->ts3_escape($queryuser) . ' client_login_password=' . $this->ts3_escape($querypass));
|
||||||
|
if (stripos($ret, "error id=0") === false) {
|
||||||
|
trigger_error("[TeamSpeakPlugin] Failed to authenticate with TS3 Server! Make sure you put the correct username & password in teamspeak.xml", E_USER_WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = '';
|
||||||
|
$response .= $this->ts3_sendCommand($socket, 'use sid=' . $this->maniaControl->settingManager->getSettingValue($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');
|
||||||
|
|
||||||
|
fputs($socket, "quit\n");
|
||||||
|
fclose($socket);
|
||||||
|
|
||||||
|
$lines = explode("error id=0 msg=ok\n\r", $response);
|
||||||
|
if (count($lines) == 5) {
|
||||||
|
$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]);
|
||||||
|
$this->serverData['users'] = array(); // reset userslist
|
||||||
|
foreach ($users as $user) {
|
||||||
|
if ($user['client_nickname'] != 'ManiaControl Viewer') {
|
||||||
|
$this->serverData['users'][] = $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtract reserved slots
|
||||||
|
$this->serverData['server']['virtualserver_maxclients'] -= $this->serverData['server']['virtualserver_reserved_slots'];
|
||||||
|
|
||||||
|
// Make ping value int
|
||||||
|
$this->serverData['server']['virtualserver_total_ping'] = intval($this->serverData['server']['virtualserver_total_ping']);
|
||||||
|
|
||||||
|
// Format the Date of server startup
|
||||||
|
$this->serverData['server']['virtualserver_uptime'] = date('Y-m-d H:i:s', (time() - $this->serverData['server']['virtualserver_uptime']));
|
||||||
|
|
||||||
|
// Always subtract all Query Clients
|
||||||
|
$this->serverData['server']['virtualserver_clientsonline'] -= $this->serverData['server']['virtualserver_queryclientsonline'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
trigger_error("[TeamSpeakPlugin] Failed to connect with TS3 server; socket error: " . $errstr . " [" . $errno . "]", E_USER_WARNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TS Function to send a command to the TeamSpeak server.
|
||||||
|
*
|
||||||
|
* @param resource $socket
|
||||||
|
* @param string $cmd
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function ts3_sendCommand($socket, $cmd) {
|
||||||
|
fputs($socket, "$cmd\n");
|
||||||
|
|
||||||
|
$response = '';
|
||||||
|
/*while(strpos($response, 'error id=') === false) {
|
||||||
|
$response .= fread($socket, 8096);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*while (!feof($socket)) {
|
||||||
|
$response .= fread($socket, 8192);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$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 escape characters in channelnames.
|
||||||
|
*
|
||||||
|
* @param string $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 parse lines in the serverresponse.
|
||||||
|
*
|
||||||
|
* @param string $rawLine
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function ts3_parseLine($rawLine) {
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
$rawItems = explode('|', $rawLine);
|
||||||
|
|
||||||
|
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 unescape characters in channelnames.
|
||||||
|
*
|
||||||
|
* @param string $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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function used insert the icon into the menu.
|
||||||
|
*/
|
||||||
|
private function addToMenu() {
|
||||||
|
$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
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->serverData = array();
|
||||||
|
|
||||||
|
$this->maniaControl->actionsMenu->removeMenuItem(1, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function handling the pressing of the icon.
|
* Function handling the pressing of the icon.
|
||||||
*
|
*
|
||||||
@ -188,7 +337,7 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
/**
|
/**
|
||||||
* Function showing the TeamSpeak widget to the player.
|
* Function showing the TeamSpeak widget to the player.
|
||||||
*
|
*
|
||||||
* @param $player
|
* @param mixed $player
|
||||||
*/
|
*/
|
||||||
private function showWidget($player) {
|
private function showWidget($player) {
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
@ -256,7 +405,7 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
$channels->setHAlign('left');
|
$channels->setHAlign('left');
|
||||||
$channels->setTextSize(1);
|
$channels->setTextSize(1);
|
||||||
$nochannels = 0;
|
$nochannels = 0;
|
||||||
foreach($this->serverData['channels'] as $channel) {
|
foreach ($this->serverData['channels'] as $channel) {
|
||||||
if ($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) {
|
if ($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -288,51 +437,51 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
$userid = 0;
|
$userid = 0;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$startx = -69.5;
|
$startx = -69.5;
|
||||||
foreach($this->serverData['channels'] as $channel) {
|
foreach ($this->serverData['channels'] as $channel) {
|
||||||
if ($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) {
|
if ($channel['channel_maxclients'] == 0 || strpos($channel['channel_name'], 'spacer') > 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$channelLabel = new Label_Text();
|
$channelLabel = new Label_Text();
|
||||||
$frame->add($channelLabel);
|
$frame->add($channelLabel);
|
||||||
$y = 17.5 + ($i * 2.5);
|
$y = 17.5 + ($i * 2.5);
|
||||||
$channelLabel->setY($height / 2 - $y);
|
$channelLabel->setY($height / 2 - $y);
|
||||||
$x = $startx;
|
$x = $startx;
|
||||||
if ($channel['pid'] != 0) {
|
if ($channel['pid'] != 0) {
|
||||||
$x = $startx + 5;
|
$x = $startx + 5;
|
||||||
}
|
}
|
||||||
$channelLabel->setX($x);
|
$channelLabel->setX($x);
|
||||||
$channelLabel->setStyle($channelLabel::STYLE_TextCardMedium);
|
$channelLabel->setStyle($channelLabel::STYLE_TextCardMedium);
|
||||||
$channelLabel->setHAlign('left');
|
$channelLabel->setHAlign('left');
|
||||||
$channelLabel->setTextSize(1);
|
$channelLabel->setTextSize(1);
|
||||||
$channelLabel->setScale(0.9);
|
$channelLabel->setScale(0.9);
|
||||||
if ($channel['channel_flag_default'] == 1) {
|
if ($channel['channel_flag_default'] == 1) {
|
||||||
$channel['total_clients'] = ($channel['total_clients'] - 1);
|
$channel['total_clients'] = ($channel['total_clients'] - 1);
|
||||||
} // remove query client
|
} // remove query client
|
||||||
$channelLabel->setText('$o' . $channel['channel_name'] . '$o (' . $channel['total_clients'] . ')');
|
$channelLabel->setText('$o' . $channel['channel_name'] . '$o (' . $channel['total_clients'] . ')');
|
||||||
$channelLabel->setTextColor('fff');
|
$channelLabel->setTextColor('fff');
|
||||||
|
|
||||||
$channels[$i] = $channelLabel;
|
$channels[$i] = $channelLabel;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
foreach($this->serverData['users'] as $user) {
|
foreach ($this->serverData['users'] as $user) {
|
||||||
if ($user['cid'] == $channel['cid']) {
|
if ($user['cid'] == $channel['cid']) {
|
||||||
$userLabel = new Label_Text();
|
$userLabel = new Label_Text();
|
||||||
$frame->add($userLabel);
|
$frame->add($userLabel);
|
||||||
$y = 17.5 + ($i * 2.5);
|
$y = 17.5 + ($i * 2.5);
|
||||||
$userLabel->setY($height / 2 - $y);
|
$userLabel->setY($height / 2 - $y);
|
||||||
if ($channel['pid'] != 0) {
|
if ($channel['pid'] != 0) {
|
||||||
$x = $startx + 7;
|
$x = $startx + 7;
|
||||||
} else {
|
} else {
|
||||||
$x = $startx + 2;
|
$x = $startx + 2;
|
||||||
}
|
}
|
||||||
$userLabel->setX($x);
|
$userLabel->setX($x);
|
||||||
$userLabel->setStyle($userLabel::STYLE_TextCardMedium);
|
$userLabel->setStyle($userLabel::STYLE_TextCardMedium);
|
||||||
$userLabel->setHAlign('left');
|
$userLabel->setHAlign('left');
|
||||||
$userLabel->setTextSize(1);
|
$userLabel->setTextSize(1);
|
||||||
$userLabel->setScale(0.9);
|
$userLabel->setScale(0.9);
|
||||||
$userLabel->setText($user['client_nickname']);
|
$userLabel->setText($user['client_nickname']);
|
||||||
$userLabel->setTextColor('fff');
|
$userLabel->setTextColor('fff');
|
||||||
$users[$userid] = $userLabel;
|
$users[$userid] = $userLabel;
|
||||||
|
|
||||||
$userid++;
|
$userid++;
|
||||||
$i++;
|
$i++;
|
||||||
@ -359,156 +508,4 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
|
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'TSViewer');
|
$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) {
|
|
||||||
$this->refreshTime = (time() + $this->refreshInterval);
|
|
||||||
|
|
||||||
$queryHost = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYHOST);
|
|
||||||
$host = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERHOST);
|
|
||||||
|
|
||||||
$host = ($queryHost != '') ? $queryHost : $host;
|
|
||||||
$queryPort = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYPORT);
|
|
||||||
|
|
||||||
$socket = fsockopen(@$host, $queryPort, $errno, $errstr, 2);
|
|
||||||
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->getSettingValue($this, self::TEAMSPEAK_QUERYUSER);
|
|
||||||
$querypass = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYPASS);
|
|
||||||
if (($queryuser != '') && !is_numeric($queryuser) && $queryuser != false && ($querypass != '') && !is_numeric($querypass) && $querypass != false) {
|
|
||||||
$ret = $this->ts3_sendCommand($socket, 'login client_login_name=' . $this->ts3_escape($queryuser) . ' client_login_password=' . $this->ts3_escape($querypass));
|
|
||||||
if (stripos($ret, "error id=0") === false) {
|
|
||||||
trigger_error("[TeamSpeakPlugin] Failed to authenticate with TS3 Server! Make sure you put the correct username & password in teamspeak.xml", E_USER_WARNING);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = '';
|
|
||||||
$response .= $this->ts3_sendCommand($socket, 'use sid=' . $this->maniaControl->settingManager->getSettingValue($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');
|
|
||||||
|
|
||||||
fputs($socket, "quit\n");
|
|
||||||
fclose($socket);
|
|
||||||
|
|
||||||
$lines = explode("error id=0 msg=ok\n\r", $response);
|
|
||||||
if (count($lines) == 5) {
|
|
||||||
$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]);
|
|
||||||
$this->serverData['users'] = array(); // reset userslist
|
|
||||||
foreach($users as $user) {
|
|
||||||
if ($user['client_nickname'] != 'ManiaControl Viewer') {
|
|
||||||
$this->serverData['users'][] = $user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subtract reserved slots
|
|
||||||
$this->serverData['server']['virtualserver_maxclients'] -= $this->serverData['server']['virtualserver_reserved_slots'];
|
|
||||||
|
|
||||||
// Make ping value int
|
|
||||||
$this->serverData['server']['virtualserver_total_ping'] = intval($this->serverData['server']['virtualserver_total_ping']);
|
|
||||||
|
|
||||||
// Format the Date of server startup
|
|
||||||
$this->serverData['server']['virtualserver_uptime'] = date('Y-m-d H:i:s', (time() - $this->serverData['server']['virtualserver_uptime']));
|
|
||||||
|
|
||||||
// Always subtract all Query Clients
|
|
||||||
$this->serverData['server']['virtualserver_clientsonline'] -= $this->serverData['server']['virtualserver_queryclientsonline'];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trigger_error("[TeamSpeakPlugin] Failed to connect with TS3 server; socket error: " . $errstr . " [" . $errno . "]", E_USER_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TS Function to send a command to the TeamSpeak server.
|
|
||||||
*
|
|
||||||
* @param $socket
|
|
||||||
* @param $cmd
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function ts3_sendCommand($socket, $cmd) {
|
|
||||||
|
|
||||||
fputs($socket, "$cmd\n");
|
|
||||||
|
|
||||||
$response = '';
|
|
||||||
/*while(strpos($response, 'error id=') === false) {
|
|
||||||
$response .= fread($socket, 8096);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*while (!feof($socket)) {
|
|
||||||
$response .= fread($socket, 8192);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$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);
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user