changed direct public property access to using getter methods
phpdoc improvements
This commit is contained in:
@ -61,8 +61,9 @@ class Player {
|
||||
public $currentTargetId = 0;
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $cache = array();
|
||||
|
||||
|
@ -48,8 +48,9 @@ class PlayerActions {
|
||||
const SETTING_PERMISSION_BAN_PLAYER = 'Ban Player';
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
@ -302,8 +303,8 @@ class PlayerActions {
|
||||
// Build Manialink
|
||||
$width = 80;
|
||||
$height = 50;
|
||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$frame = new Frame();
|
||||
|
@ -30,8 +30,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
const SETTING_PERMISSION_TEAM_BALANCE = 'Balance Teams';
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
@ -133,7 +134,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->playerManager->playerActions->kickPlayer($player->login, $targetLogin, $message);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->kickPlayer($player->login, $targetLogin, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +158,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->playerManager->playerActions->banPlayer($player->login, $targetLogin, $message);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->banPlayer($player->login, $targetLogin, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +174,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
$this->maniaControl->playerManager->playerActions->warnPlayer($player->login, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->warnPlayer($player->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,9 +197,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = (int)$params[2];
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
} else {
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +227,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
}
|
||||
$selectable = ($type === 2);
|
||||
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -247,7 +248,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,7 +269,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,7 +327,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
return;
|
||||
}
|
||||
$targetLogin = $commandParts[1];
|
||||
$this->maniaControl->playerManager->playerActions->mutePlayer($admin->login, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->mutePlayer($admin->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,7 +343,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
return;
|
||||
}
|
||||
$targetLogin = $commandParts[1];
|
||||
$this->maniaControl->playerManager->playerActions->unMutePlayer($admin->login, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->unMutePlayer($admin->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -352,7 +353,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_playerList(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->playerManager->playerList->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
||||
$this->maniaControl->playerManager->playerList->showPlayerList($player);
|
||||
$this->maniaControl->playerManager->getPlayerList()->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
||||
$this->maniaControl->playerManager->getPlayerList()->showPlayerList($player);
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,13 @@ class PlayerDataManager {
|
||||
const TYPE_REAL = 'real';
|
||||
const TYPE_BOOL = 'bool';
|
||||
const TYPE_ARRAY = 'array';
|
||||
const ARRAY_DELIMITER = ';;';
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $arrayDelimiter = ';;';
|
||||
private $metaData = array();
|
||||
private $storedData = array();
|
||||
|
||||
@ -339,7 +340,7 @@ class PlayerDataManager {
|
||||
return (string)$value;
|
||||
}
|
||||
if ($type === self::TYPE_ARRAY) {
|
||||
return explode($this->arrayDelimiter, $value);
|
||||
return explode(self::ARRAY_DELIMITER, $value);
|
||||
}
|
||||
trigger_error('Unsupported data type. ' . print_r($type, true));
|
||||
return $value;
|
||||
|
@ -28,8 +28,9 @@ class PlayerDetailed {
|
||||
const STATS_PER_COLUMN = 13;
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
@ -41,10 +42,10 @@ class PlayerDetailed {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// settings
|
||||
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||
$this->width = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsWidth();
|
||||
$this->height = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsHeight();
|
||||
$this->quadStyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$this->quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,7 +63,7 @@ class PlayerDetailed {
|
||||
$script = $maniaLink->getScript();
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script);
|
||||
$frame = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultListFrame($script);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Create script and features
|
||||
|
@ -59,8 +59,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
const MAX_PLAYERS_PER_PAGE = 15;
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $playersListShown = array();
|
||||
|
||||
@ -133,8 +134,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showPlayerList(Player $player) {
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
// get PlayerList
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
@ -146,7 +147,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@ -154,7 +155,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$posY = $height / 2;
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@ -425,10 +426,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
*/
|
||||
public function showAdvancedPlayerWidget(Player $admin, $login) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||
$width = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
//Settings
|
||||
$posX = $width / 2 + 2.5;
|
||||
@ -505,7 +506,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$label->setTextSize($textSize);
|
||||
$label->setTextColor($textColor);
|
||||
|
||||
if (!$this->maniaControl->playerManager->playerActions->isPlayerMuted($login)) {
|
||||
if (!$this->maniaControl->playerManager->getPlayerActions()->isPlayerMuted($login)) {
|
||||
$label->setText('Mute');
|
||||
$quad->setAction(self::ACTION_MUTE_PLAYER . '.' . $login);
|
||||
} else {
|
||||
@ -636,53 +637,53 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
break;
|
||||
case self::ACTION_OPEN_PLAYER_DETAILED:
|
||||
$player = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
$this->maniaControl->playerManager->playerDetailed->showPlayerDetailed($player, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerDetailed()->showPlayerDetailed($player, $targetLogin);
|
||||
unset($this->playersListShown[$player->login]);
|
||||
break;
|
||||
case self::ACTION_FORCE_BLUE:
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
break;
|
||||
case self::ACTION_FORCE_RED:
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
|
||||
break;
|
||||
case self::ACTION_FORCE_SPEC:
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
break;
|
||||
case self::ACTION_FORCE_PLAY:
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->forcePlayerToPlay($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_MUTE_PLAYER:
|
||||
$this->maniaControl->playerManager->playerActions->mutePlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->mutePlayer($adminLogin, $targetLogin);
|
||||
$this->showPlayerList($this->maniaControl->playerManager->getPlayer($adminLogin));
|
||||
break;
|
||||
case self::ACTION_UNMUTE_PLAYER:
|
||||
$this->maniaControl->playerManager->playerActions->unMutePlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->unMutePlayer($adminLogin, $targetLogin);
|
||||
$this->showPlayerList($this->maniaControl->playerManager->getPlayer($adminLogin));
|
||||
break;
|
||||
case self::ACTION_WARN_PLAYER:
|
||||
$this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->warnPlayer($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_KICK_PLAYER:
|
||||
$this->maniaControl->playerManager->playerActions->kickPlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->kickPlayer($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_BAN_PLAYER:
|
||||
$this->maniaControl->playerManager->playerActions->banPlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->banPlayer($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_PLAYER_ADV:
|
||||
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
$this->advancedPlayerWidget($admin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_ADD_AS_MASTER:
|
||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
break;
|
||||
case self::ACTION_ADD_AS_ADMIN:
|
||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
break;
|
||||
case self::ACTION_ADD_AS_MOD:
|
||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
break;
|
||||
case self::ACTION_REVOKE_RIGHTS:
|
||||
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
$this->maniaControl->playerManager->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_FORCE_SPEC_VOTE:
|
||||
/** @var $votesPlugin CustomVotesPlugin */
|
||||
|
@ -33,17 +33,31 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
const STAT_SERVERTIME = 'Servertime';
|
||||
|
||||
/*
|
||||
* Public Properties
|
||||
* Public properties
|
||||
*/
|
||||
/** @var PlayerActions $playerActions */
|
||||
/** @deprecated see getPlayerActions() */
|
||||
public $playerActions = null;
|
||||
/** @var PlayerCommands $playerCommands */
|
||||
/** @deprecated see getPlayerCommands() */
|
||||
public $playerCommands = null;
|
||||
/** @var PlayerDetailed $playerDetailed */
|
||||
/** @deprecated see getPlayerDetailed() */
|
||||
public $playerDetailed = null;
|
||||
/** @var PlayerDataManager $playerDataManager */
|
||||
/** @deprecated see getPlayerDataManager() */
|
||||
public $playerDataManager = null;
|
||||
/** @var PlayerList $playerList */
|
||||
/** @deprecated see getPlayerList() */
|
||||
public $playerList = null;
|
||||
/** @var AdminLists $adminLists */
|
||||
/** @deprecated see getAdminLists() */
|
||||
public $adminLists = null;
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var Player[] $players */
|
||||
private $players = array();
|
||||
@ -110,6 +124,51 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player actions
|
||||
*
|
||||
* @return PlayerActions
|
||||
*/
|
||||
public function getPlayerActions() {
|
||||
return $this->playerActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player commands
|
||||
*
|
||||
* @return PlayerCommands
|
||||
*/
|
||||
public function getPlayerCommands() {
|
||||
return $this->playerCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player detailed
|
||||
*
|
||||
* @return PlayerDetailed
|
||||
*/
|
||||
public function getPlayerDetailed() {
|
||||
return $this->playerDetailed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player list
|
||||
*
|
||||
* @return PlayerList
|
||||
*/
|
||||
public function getPlayerList() {
|
||||
return $this->playerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get admin lists
|
||||
*
|
||||
* @return AdminLists
|
||||
*/
|
||||
public function getAdminLists() {
|
||||
return $this->adminLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle OnInit callback
|
||||
*/
|
||||
@ -152,7 +211,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save player in Database and fill up Object Properties
|
||||
* Save player in database and fill up properties
|
||||
*
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
@ -295,7 +354,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Count of all Player
|
||||
* Get the count of all Players
|
||||
*
|
||||
* @param bool $withoutSpectators
|
||||
* @return int
|
||||
@ -363,7 +422,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Player by Login
|
||||
* Get a Player by login
|
||||
*
|
||||
* @param mixed $login
|
||||
* @param bool $connectedPlayersOnly
|
||||
@ -383,7 +442,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Player from the Database
|
||||
* Get a Player from the database
|
||||
*
|
||||
* @param string $playerLogin
|
||||
* @return Player
|
||||
@ -427,7 +486,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Count of all Spectators
|
||||
* Get the count of all spectators
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@ -442,7 +501,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Player by his Index
|
||||
* Get a Player by index
|
||||
*
|
||||
* @param int $index
|
||||
* @param bool $connectedPlayersOnly
|
||||
@ -455,27 +514,28 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
}
|
||||
|
||||
if ($connectedPlayersOnly) {
|
||||
return null;
|
||||
// Player is not online - Get Player from Database
|
||||
if (!$connectedPlayersOnly) {
|
||||
return $this->getPlayerFromDatabaseByIndex($index);
|
||||
}
|
||||
//Player is not online -> get Player from Database
|
||||
return $this->getPlayerFromDatabaseByIndex($index);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Player out of the database
|
||||
*
|
||||
* @param int $playerIndex
|
||||
* @return Player $player
|
||||
* @return Player
|
||||
*/
|
||||
private function getPlayerFromDatabaseByIndex($playerIndex) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
|
||||
if (!is_numeric($playerIndex)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM `" . self::TABLE_PLAYERS . "` WHERE `index` = " . $playerIndex . ";";
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$query = "SELECT * FROM `" . self::TABLE_PLAYERS . "`
|
||||
WHERE `index` = {$playerIndex};";
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
trigger_error($mysqli->error);
|
||||
@ -485,7 +545,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$row = $result->fetch_object();
|
||||
$result->free();
|
||||
|
||||
if (!isset($row)) {
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user