structural changes for v0.2

This commit is contained in:
kremsy 2017-03-22 17:57:21 +01:00
parent df2d548755
commit 60524e9244
3 changed files with 83 additions and 24 deletions

View File

@ -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';
@ -171,8 +172,13 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
/** @var EchoManager $echoManager */
private $echoManager = null;
/** @var CommunicationManager $communicationManager */
private $communicationManager = null;
/** @var ModeScriptEventManager $modeScriptEventManager */
private $modeScriptEventManager = null;
/**
* Construct a new ManiaControl instance
*/
@ -185,6 +191,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
// Load ManiaControl Modules
$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);
@ -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!');
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Manager for Mode Script Events
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @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'));
}
}

View File

@ -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;
}