Load the author nickname of a map when the author is known

This commit is contained in:
Beu 2022-03-12 19:34:39 +01:00
parent b4228a19c8
commit d5faaf57ff
2 changed files with 17 additions and 3 deletions

View File

@ -8,6 +8,8 @@ use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaExchange\MXMapInfo;
use ManiaControl\Utils\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* ManiaControl Map Model Class
@ -52,12 +54,19 @@ class Map implements Dumpable, UsageInformationAble {
public $lastUpdate = 0;
public $karma = null;
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/**
* Construct a new map instance from xmlrpc data
*
* @param \Maniaplanet\DedicatedServer\Structures\Map $mpMap
*/
public function __construct($mpMap = null) {
public function __construct(ManiaControl $maniaControl, $mpMap = null) {
$this->maniaControl = $maniaControl;
$this->startTime = time();
if (!$mpMap) {
@ -79,7 +88,12 @@ class Map implements Dumpable, UsageInformationAble {
$this->nbCheckpoints = $mpMap->nbCheckpoints;
$this->nbLaps = $mpMap->nbLaps;
$this->authorNick = $this->authorLogin;
$player = $this->maniaControl->getPlayerManager()->getPlayer($this->authorLogin);
if ($player) {
$this->authorNick = $player->nickname;
} else {
$this->authorNick = $this->authorLogin;
}
}
/**

View File

@ -595,7 +595,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
* @return Map
*/
public function initializeMap($rpcMap) {
$map = new Map($rpcMap);
$map = new Map($this->maniaControl, $rpcMap);
$this->saveMap($map);
return $map;
}