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 ONINIT = 'Callbacks.OnInit';
const AFTERINIT = 'Callbacks.AfterInit'; const AFTERINIT = 'Callbacks.AfterInit';
const ONSHUTDOWN = 'Callbacks.OnShutdown'; const ONSHUTDOWN = 'Callbacks.OnShutdown';
/** @deprecated */
const ONRESTART = 'Callbacks.OnRestart'; const ONRESTART = 'Callbacks.OnRestart';
const ONREBOOT = 'Callbacks.OnReboot';
const PRELOOP = 'Callbacks.PreLoop'; const PRELOOP = 'Callbacks.PreLoop';
const AFTERLOOP = 'Callbacks.AfterLoop'; const AFTERLOOP = 'Callbacks.AfterLoop';

View File

@ -143,8 +143,9 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl
} }
switch ($name) { switch ($name) {
case 'ManiaControl.Restart': case Callbacks::ONRESTART:
$this->maniaControl->restart($message); case Callbacks::ONREBOOT:
$this->maniaControl->reboot($message);
break; break;
default: default:
$this->triggerEchoCallback($name, $message); $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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface CommunicationMethods { interface CommunicationMethods {
/** Restarts Mania Control /** Reboots Mania Control
* Optional Params * Optional Params
* - message * - message
*/ */
const RESTART_MANIA_CONTROL = "ManiaControl.Restart"; const REBOOT_MANIA_CONTROL = "ManiaControl.Reboot";
/** Update the ManiaControl Core */ /** Update the ManiaControl Core */
const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate"; const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate";

View File

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

View File

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