fixed null issue
This commit is contained in:
parent
79a5a451c2
commit
50547437f7
@ -121,6 +121,23 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
$this->resetRanks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create necessary database tables
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RANK . "` (
|
||||
`PlayerIndex` int(11) NOT NULL,
|
||||
`Rank` int(11) NOT NULL,
|
||||
`Avg` float NOT NULL,
|
||||
KEY `PlayerIndex` (`PlayerIndex`),
|
||||
UNIQUE `Rank` (`Rank`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='ServerRanking';";
|
||||
$mysqli->query($query);
|
||||
if ($mysqli->error) {
|
||||
throw new \Exception($mysqli->error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RankingsTypeArray
|
||||
@ -141,24 +158,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create necessary database tables
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RANK . "` (
|
||||
`PlayerIndex` int(11) NOT NULL,
|
||||
`Rank` int(11) NOT NULL,
|
||||
`Avg` float NOT NULL,
|
||||
KEY `PlayerIndex` (`PlayerIndex`),
|
||||
UNIQUE `Rank` (`Rank`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='ServerRanking';";
|
||||
$mysqli->query($query);
|
||||
if ($mysqli->error) {
|
||||
throw new \Exception($mysqli->error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets and rebuilds the Ranking
|
||||
*/
|
||||
@ -368,12 +367,18 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
$nextPlayer = null;
|
||||
if ($rankObject->rank > 1) {
|
||||
$nextRank = $this->getNextRank($player);
|
||||
if ($nextRank) {
|
||||
$nextPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($nextRank->playerIndex);
|
||||
$message = '$0f3The next better ranked player is $fff' . $nextPlayer->nickname;
|
||||
}
|
||||
}
|
||||
|
||||
if ($nextPlayer) {
|
||||
$message = '$0f3The next better ranked player is $fff' . $nextPlayer->getEscapedNickname() . '!';
|
||||
} else {
|
||||
$message = '$0f3No better ranked player :-)';
|
||||
$message = '$0f3No better ranked player.';
|
||||
}
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user