diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 34c74067..aa23f0da 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -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'; diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index 5bad9475..b095f2af 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -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); diff --git a/core/Communication/CommunicationMethods.php b/core/Communication/CommunicationMethods.php index 8f47de38..33120016 100644 --- a/core/Communication/CommunicationMethods.php +++ b/core/Communication/CommunicationMethods.php @@ -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"; diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 611dd772..05de9916 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -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.'); diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 9e8a42df..c6694d39 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -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.'); } /** diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index 0550c636..6226505f 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -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.'); diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 6b4b54be..a8ffabf1 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -408,7 +408,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, } Logger::log($message); - $this->maniaControl->restart(); + $this->maniaControl->reboot(); }); $asyncHttpRequest->getData();