prevent error through non-object

This commit is contained in:
Steffen Schröder 2014-06-15 00:05:43 +02:00
parent 81706481f2
commit c69c14a0c6

View File

@ -11,7 +11,6 @@ use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Maps\Map;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager; use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
@ -402,10 +401,13 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
* @return Rank * @return Rank
*/ */
private function getNextRank(Player $player) { private function getNextRank(Player $player) {
$mysqli = $this->maniaControl->database->mysqli;
$rankObject = $this->getRank($player); $rankObject = $this->getRank($player);
$nextRank = $rankObject->rank - 1; if (!$rankObject) {
return null;
}
$nextRank = $rankObject->rank - 1;
$mysqli = $this->maniaControl->database->mysqli;
$query = "SELECT * FROM `" . self::TABLE_RANK . "` $query = "SELECT * FROM `" . self::TABLE_RANK . "`
WHERE `Rank` = {$nextRank}"; WHERE `Rank` = {$nextRank}";
$result = $mysqli->query($query); $result = $mysqli->query($query);
@ -424,11 +426,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
} }
/** /**
* Shows Ranks on endMap * Show Ranks on Map End
*
* @param Map $map
*/ */
public function handleEndMap(Map $map) { public function handleEndMap() {
$this->resetRanks(); $this->resetRanks();
foreach ($this->maniaControl->playerManager->getPlayers() as $player) { foreach ($this->maniaControl->playerManager->getPlayers() as $player) {