Changed /topdons to use StatisticsManager

This commit is contained in:
Max Klaversma 2014-05-02 17:50:22 +02:00
parent 7469d97712
commit f2f725a4ff

View File

@ -477,13 +477,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
* @return null * @return null
*/ */
private function showTopDonsList(Player $player) { private function showTopDonsList(Player $player) {
$query = "SELECT * FROM `".StatisticManager::TABLE_STATISTICS."` WHERE `statId` = 3 ORDER BY `value` DESC LIMIT 0, 100"; $stats = $this->maniaControl->statisticManager->getStatsRanking(self::STAT_PLAYER_DONATIONS);
$mysqli = $this->maniaControl->database->mysqli;
$result = $mysqli->query($query);
if ($mysqli->error) {
trigger_error($mysqli->error);
return null;
}
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth(); $width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight(); $height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
@ -516,7 +510,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$i = 1; $i = 1;
$y = $y - 10; $y = $y - 10;
$pageFrames = array(); $pageFrames = array();
while($donator = $result->fetch_object()) { foreach($stats as $playerIndex => $donations) {
if (!isset($pageFrame)) { if (!isset($pageFrame)) {
$pageFrame = new Frame(); $pageFrame = new Frame();
$frame->add($pageFrame); $frame->add($pageFrame);
@ -541,8 +535,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$lineQuad->setZ(0.001); $lineQuad->setZ(0.001);
} }
$donatingPlayer = $this->maniaControl->playerManager->getPlayerByIndex($donator->playerId); $donatingPlayer = $this->maniaControl->playerManager->getPlayerByIndex($playerIndex);
$array = array($i => $x + 5, $donatingPlayer->nickname => $x + 18, $donator->value => $x + 70); $array = array($i => $x + 5, $donatingPlayer->nickname => $x + 18, $donations => $x + 70);
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
$y -= 4; $y -= 4;
@ -550,6 +544,10 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
if (($i - 1) % 15 == 0) { if (($i - 1) % 15 == 0) {
unset($pageFrame); unset($pageFrame);
} }
if($i > 100) {
break;
}
} }
// Render and display xml // Render and display xml