small callback stability improvement

This commit is contained in:
kremsy 2017-05-09 19:11:19 +02:00
parent 05f688b99f
commit 37e12ebf88
2 changed files with 29 additions and 24 deletions

View File

@ -30,8 +30,11 @@ class OnScoresStructure extends CommonScoresStructure {
$jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) {
$player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
if($player){
$playerScore = new PlayerScore();
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
@ -39,6 +42,6 @@ class OnScoresStructure extends CommonScoresStructure {
$this->playerScores[$jsonPlayer->login] = $playerScore;
}
}
}
}

View File

@ -4,7 +4,6 @@ namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
use ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore;
use ManiaControl\ManiaControl;
/**
@ -29,6 +28,8 @@ class OnScoresStructure extends CommonScoresStructure {
$jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) {
$player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
if ($player) {
$playerScore = new PlayerScore();
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setRank($jsonPlayer->rank);
@ -46,3 +47,4 @@ class OnScoresStructure extends CommonScoresStructure {
}
}
}
}