CommunicationManager added Coreupdate
This commit is contained in:
parent
af10e2c530
commit
5d6f8d047c
@ -16,6 +16,9 @@ interface CommunicationMethods {
|
|||||||
*/
|
*/
|
||||||
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
|
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
|
||||||
|
|
||||||
|
/** Update the ManiaControl Core */
|
||||||
|
const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate";
|
||||||
|
|
||||||
/** Grands an Authentication Level on a Player
|
/** Grands an Authentication Level on a Player
|
||||||
* Required Parameters
|
* Required Parameters
|
||||||
* - login (login of the player)
|
* - login (login of the player)
|
||||||
|
@ -6,6 +6,9 @@ use ManiaControl\Admin\AuthenticationManager;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
|
use ManiaControl\Communication\CommunicationAnswer;
|
||||||
|
use ManiaControl\Communication\CommunicationListener;
|
||||||
|
use ManiaControl\Communication\CommunicationMethods;
|
||||||
use ManiaControl\Files\AsyncHttpRequest;
|
use ManiaControl\Files\AsyncHttpRequest;
|
||||||
use ManiaControl\Files\BackupUtil;
|
use ManiaControl\Files\BackupUtil;
|
||||||
use ManiaControl\Files\FileUtil;
|
use ManiaControl\Files\FileUtil;
|
||||||
@ -21,7 +24,7 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
* @copyright 2014-2017 ManiaControl Team
|
* @copyright 2014-2017 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class UpdateManager implements CallbackListener, CommandListener, TimerListener {
|
class UpdateManager implements CallbackListener, CommandListener, TimerListener, CommunicationListener {
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -80,6 +83,12 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
|
|
||||||
// Children
|
// Children
|
||||||
$this->pluginUpdateManager = new PluginUpdateManager($maniaControl);
|
$this->pluginUpdateManager = new PluginUpdateManager($maniaControl);
|
||||||
|
|
||||||
|
// Communication Methods
|
||||||
|
$this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::UPDATE_MANIA_CONTROL_CORE, $this, function ($data) {
|
||||||
|
$this->checkAndHandleCoreUpdate();
|
||||||
|
return new CommunicationAnswer();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -502,13 +511,26 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->checkAndHandleCoreUpdate($player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle CoreUpdate Asnyc
|
||||||
|
*
|
||||||
|
* @param null $player
|
||||||
|
*/
|
||||||
|
private function checkAndHandleCoreUpdate($player = null) {
|
||||||
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) {
|
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) {
|
||||||
if (!$updateData) {
|
if (!$updateData) {
|
||||||
$this->maniaControl->getChat()->sendError('Update is currently not possible!', $player);
|
if ($player) {
|
||||||
|
$this->maniaControl->getChat()->sendError('Update is currently not possible!', $player);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->checkUpdateDataBuildVersion($updateData)) {
|
if (!$this->checkUpdateDataBuildVersion($updateData)) {
|
||||||
$this->maniaControl->getChat()->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player);
|
if ($player) {
|
||||||
|
$this->maniaControl->getChat()->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user