small fixes
This commit is contained in:
parent
b5d63d796d
commit
6eef55df6d
@ -22,7 +22,7 @@ class OnPlayerRequestActionChange extends BaseStructure {
|
|||||||
parent::__construct($maniaControl, $data);
|
parent::__construct($maniaControl, $data);
|
||||||
|
|
||||||
$this->time = $this->getPlainJsonObject()->time;
|
$this->time = $this->getPlainJsonObject()->time;
|
||||||
$this->actionChange = $this->getPlainJsonObject()->actionChange;
|
$this->actionChange = $this->getPlainJsonObject()->actionchange;
|
||||||
|
|
||||||
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
|
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class AsyncHttpRequest implements UsageInformationAble {
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const CONTENT_TYPE_JSON = 'application/json';
|
const CONTENT_TYPE_JSON = 'application/json';
|
||||||
|
const CONTENT_TYPE_UTF8 = 'UTF-8';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
|
@ -9,6 +9,7 @@ use ManiaControl\Callbacks\Callbacks;
|
|||||||
use ManiaControl\Communication\CommunicationAnswer;
|
use ManiaControl\Communication\CommunicationAnswer;
|
||||||
use ManiaControl\Communication\CommunicationListener;
|
use ManiaControl\Communication\CommunicationListener;
|
||||||
use ManiaControl\Communication\CommunicationMethods;
|
use ManiaControl\Communication\CommunicationMethods;
|
||||||
|
use ManiaControl\Files\AsyncHttpRequest;
|
||||||
use ManiaControl\Files\FileUtil;
|
use ManiaControl\Files\FileUtil;
|
||||||
use ManiaControl\General\UsageInformationAble;
|
use ManiaControl\General\UsageInformationAble;
|
||||||
use ManiaControl\General\UsageInformationTrait;
|
use ManiaControl\General\UsageInformationTrait;
|
||||||
@ -360,12 +361,14 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
|
|
||||||
$url = $mapInfo->downloadurl;
|
$url = $mapInfo->downloadurl;
|
||||||
|
|
||||||
if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this, ManiaExchangeManager::SETTING_MX_KEY)) {
|
if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this->getMXManager(), ManiaExchangeManager::SETTING_MX_KEY)) {
|
||||||
$url .= "&key=" . $key;
|
$url .= "?key=" . $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download the file
|
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url);
|
||||||
$this->maniaControl->getFileReader()->loadFile($url, function ($file, $error) use (
|
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_UTF8);
|
||||||
|
$asyncHttpRequest->setHeaders(array("X-ManiaPlanet-ServerLogin: " . $this->maniaControl->getServer()->login));
|
||||||
|
$asyncHttpRequest->setCallable(function ($file, $error) use (
|
||||||
&$login, &$mapInfo, &$update
|
&$login, &$mapInfo, &$update
|
||||||
) {
|
) {
|
||||||
if (!$file || $error) {
|
if (!$file || $error) {
|
||||||
@ -376,7 +379,9 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->processMapFile($file, $mapInfo, $login, $update);
|
$this->processMapFile($file, $mapInfo, $login, $update);
|
||||||
}, 'UTF-8', 0, array("X-ManiaPlanet-ServerLogin: " . $this->maniaControl->getServer()->login));
|
});
|
||||||
|
|
||||||
|
$asyncHttpRequest->getData();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -455,7 +460,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($exception, $login);
|
||||||
return;
|
return;
|
||||||
} catch (InvalidMapException $exception) {
|
} catch (InvalidMapException $exception) {
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($exception, $login);
|
||||||
if ($exception->getMessage() != 'Map lightmap is not up to date. (will still load for now)') {
|
if ($exception->getMessage() != 'Map lightmap is not up to date. (will still load for now)') {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user