Renamed //restart to //reboot

This commit is contained in:
Alexander Nell 2020-04-24 18:51:38 +02:00
parent 8d9af39797
commit c2064c8d78
7 changed files with 30 additions and 27 deletions

View File

@ -16,7 +16,9 @@ interface Callbacks {
const ONINIT = 'Callbacks.OnInit';
const AFTERINIT = 'Callbacks.AfterInit';
const ONSHUTDOWN = 'Callbacks.OnShutdown';
/** @deprecated */
const ONRESTART = 'Callbacks.OnRestart';
const ONREBOOT = 'Callbacks.OnReboot';
const PRELOOP = 'Callbacks.PreLoop';
const AFTERLOOP = 'Callbacks.AfterLoop';

View File

@ -143,8 +143,9 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl
}
switch ($name) {
case 'ManiaControl.Restart':
$this->maniaControl->restart($message);
case Callbacks::ONRESTART:
case Callbacks::ONREBOOT:
$this->maniaControl->reboot($message);
break;
default:
$this->triggerEchoCallback($name, $message);

View File

@ -10,11 +10,11 @@ namespace ManiaControl\Communication;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
interface CommunicationMethods {
/** Restarts Mania Control
/** Reboots Mania Control
* Optional Params
* - message
*/
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
const REBOOT_MANIA_CONTROL = "ManiaControl.Reboot";
/** Update the ManiaControl Core */
const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate";

View File

@ -199,7 +199,7 @@ class ErrorHandler {
if ($isFatalError) {
if ($isPluginError) {
$this->maniaControl->restart();
$this->maniaControl->reboot();
} else {
$this->maniaControl->quit('Quitting ManiaControl after Fatal Error.');
}
@ -513,7 +513,7 @@ class ErrorHandler {
if ($shutdown) {
if ($this->shouldRestart()) {
$this->maniaControl->restart();
$this->maniaControl->reboot();
}
try {
$this->maniaControl->quit('Quitting ManiaControl after Exception.');

View File

@ -61,7 +61,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
const SCRIPT_TIMEOUT = 40;
const URL_WEBSERVICE = 'https://ws.maniacontrol.com/';
const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl';
const SETTING_PERMISSION_RESTART = 'Restart ManiaControl';
const SETTING_PERMISSION_REBOOT = 'Reboot ManiaControl';
/*
* Public properties
@ -223,24 +223,24 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
// Permissions
$this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
$this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_RESTART, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
$this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_REBOOT, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
// Commands
$this->getCommandManager()->registerCommandListener('version', $this, 'commandVersion', false, 'Shows ManiaControl version.');
$this->getCommandManager()->registerCommandListener('restart', $this, 'commandRestart', true, 'Restarts ManiaControl.');
$this->getCommandManager()->registerCommandListener('reboot', $this, 'commandReboot', true, 'Reboots ManiaControl.');
$this->getCommandManager()->registerCommandListener('shutdown', $this, 'commandShutdown', true, 'Shuts ManiaControl down.');
// Check connection every 30 seconds
$this->getTimerManager()->registerTimerListening($this, 'checkConnection', 1000 * 30);
// Communication Methods
$this->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::RESTART_MANIA_CONTROL, $this, function ($data) {
$this->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::REBOOT_MANIA_CONTROL, $this, function ($data) {
//Delay Shutdown to send answer first
$this->getTimerManager()->registerOneTimeListening($this, function () use ($data) {
if (is_object($data) && property_exists($data, "message")) {
$this->restart($data->message);
$this->reboot($data->message);
} else {
$this->restart();
$this->reboot();
}
}, 3000);
return new CommunicationAnswer();
@ -536,42 +536,42 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
}
/**
* Handle Restart AdminCommand
* Handle Reboot AdminCommand
*
* @param array $chatCallback
* @param Player $player
*/
public function commandRestart(array $chatCallback, Player $player) {
if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_RESTART)) {
public function commandReboot(array $chatCallback, Player $player) {
if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_REBOOT)) {
$this->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$this->restart("ManiaControl Restart requested by '{$player->login}'!");
$this->reboot("ManiaControl Reboot requested by '{$player->login}'!");
}
/**
* Restart ManiaControl
* Reboot ManiaControl
*
* @param string $message
*/
public function restart($message = null) {
// Trigger callback on Restart
$this->getCallbackManager()->triggerCallback(Callbacks::ONRESTART);
public function reboot($message = null) {
// Trigger callback on Reboot
$this->getCallbackManager()->triggerCallback(Callbacks::ONREBOOT);
// Announce restart
// Announce reboot
try {
$this->getChat()->sendInformation('Restarting ManiaControl...', null, true, false);
$this->getChat()->sendInformation('Rebooting ManiaControl...', null, true, false);
} catch (TransportException $e) {
}
Logger::log('Restarting ManiaControl... ' . $message);
Logger::log('Rebooting ManiaControl... ' . $message);
// Start new instance
if (!defined('PHP_UNIT_TEST')) {
SystemUtil::restart();
SystemUtil::reboot();
}
// Quit old instance
$this->quit('Quitting ManiaControl to restart.');
$this->quit('Quitting ManiaControl to reboot.');
}
/**

View File

@ -51,7 +51,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
// Admin commands
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'restart', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('replaymap', 'replay'), $this, 'command_ReplayMap', true, 'Replays the current map (after the end of the map).');
$this->maniaControl->getCommandManager()->registerCommandListener(array('addmap', 'add'), $this, 'command_AddMap', true, 'Adds map from ManiaExchange.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('removemap', 'removethis'), $this, 'command_RemoveMap', true, 'Removes the current map.');

View File

@ -408,7 +408,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
}
Logger::log($message);
$this->maniaControl->restart();
$this->maniaControl->reboot();
});
$asyncHttpRequest->getData();