From 60524e924435d1845d112c7ce496e0b8d312892a Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Mar 2017 17:57:21 +0100 Subject: [PATCH] structural changes for v0.2 --- core/ManiaControl.php | 62 ++++++++++++++++---------- core/Server/ModeScriptEventManager.php | 41 +++++++++++++++++ core/Server/ScriptManager.php | 4 +- 3 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 core/Server/ModeScriptEventManager.php diff --git a/core/ManiaControl.php b/core/ManiaControl.php index a32be38a..dd28a694 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -26,6 +26,7 @@ use ManiaControl\Maps\MapManager; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\PluginManager; +use ManiaControl\Server\ModeScriptEventManager; use ManiaControl\Server\Server; use ManiaControl\Settings\SettingManager; use ManiaControl\Statistics\StatisticManager; @@ -47,11 +48,11 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.166'; + const VERSION = '0.200'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2014-04-02_18_00'; const SCRIPT_TIMEOUT = 10; - const URL_WEBSERVICE = 'https://ws.maniacontrol.com/'; + const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl'; const SETTING_PERMISSION_RESTART = 'Restart ManiaControl'; @@ -170,9 +171,14 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, private $requestQuitMessage = null; /** @var EchoManager $echoManager */ - private $echoManager = null; + private $echoManager = null; + + /** @var CommunicationManager $communicationManager */ private $communicationManager = null; + /** @var ModeScriptEventManager $modeScriptEventManager */ + private $modeScriptEventManager = null; + /** * Construct a new ManiaControl instance */ @@ -184,26 +190,27 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->loadConfig(); // Load ManiaControl Modules - $this->callbackManager = new CallbackManager($this); - $this->echoManager = new EchoManager($this); - $this->communicationManager = new CommunicationManager($this); - $this->timerManager = new TimerManager($this); - $this->database = new Database($this); - $this->fileReader = new AsynchronousFileReader($this); - $this->billManager = new BillManager($this); - $this->settingManager = new SettingManager($this); - $this->statisticManager = new StatisticManager($this); - $this->manialinkManager = new ManialinkManager($this); - $this->actionsMenu = new ActionsMenu($this); - $this->chat = new Chat($this); - $this->commandManager = new CommandManager($this); - $this->server = new Server($this); - $this->authenticationManager = new AuthenticationManager($this); - $this->playerManager = new PlayerManager($this); - $this->mapManager = new MapManager($this); - $this->configurator = new Configurator($this); - $this->pluginManager = new PluginManager($this); - $this->updateManager = new UpdateManager($this); + $this->callbackManager = new CallbackManager($this); + $this->modeScriptEventManager = new ModeScriptEventManager($this); + $this->echoManager = new EchoManager($this); + $this->communicationManager = new CommunicationManager($this); + $this->timerManager = new TimerManager($this); + $this->database = new Database($this); + $this->fileReader = new AsynchronousFileReader($this); + $this->billManager = new BillManager($this); + $this->settingManager = new SettingManager($this); + $this->statisticManager = new StatisticManager($this); + $this->manialinkManager = new ManialinkManager($this); + $this->actionsMenu = new ActionsMenu($this); + $this->chat = new Chat($this); + $this->commandManager = new CommandManager($this); + $this->server = new Server($this); + $this->authenticationManager = new AuthenticationManager($this); + $this->playerManager = new PlayerManager($this); + $this->mapManager = new MapManager($this); + $this->configurator = new Configurator($this); + $this->pluginManager = new PluginManager($this); + $this->updateManager = new UpdateManager($this); $this->getErrorHandler()->init(); @@ -467,6 +474,13 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, return $this->billManager; } + /** + * @return ModeScriptEventManager + */ + public function getModeScriptEventManager() { + return $this->modeScriptEventManager; + } + /** * Check connection */ @@ -699,4 +713,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, public function handleServerStopCallback() { $this->requestQuit('The Server has been shut down!'); } + + } diff --git a/core/Server/ModeScriptEventManager.php b/core/Server/ModeScriptEventManager.php new file mode 100644 index 00000000..500d78ae --- /dev/null +++ b/core/Server/ModeScriptEventManager.php @@ -0,0 +1,41 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +namespace ManiaControl\Server; + +//TODO maybe own folder + +use ManiaControl\ManiaControl; + +class ModeScriptEventManager { + /** @var ManiaControl $maniaControl */ + private $maniaControl; + + /** + * Construct a new ranking manager instance + * + * @param ManiaControl $maniaControl + */ + public function __construct(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + } + + /** + * Enables XmlRpc Callbacks + */ + public function enableCallbacks() { + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); + } + + /** + * Disables XmlRpc Callbacks + */ + public function disableCallbacks() { + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false')); + } +} \ No newline at end of file diff --git a/core/Server/ScriptManager.php b/core/Server/ScriptManager.php index 177ddbe0..a6e232e2 100644 --- a/core/Server/ScriptManager.php +++ b/core/Server/ScriptManager.php @@ -47,7 +47,9 @@ class ScriptManager { return false; } - $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); + //TODO verify that the old S_ isnt needed anymore + + $this->maniaControl->getModeScriptEventManager()->enableCallbacks(); Logger::logInfo("Script Callbacks successfully enabled!"); return true; }