diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index f90dc17b..0b46a5e3 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -36,7 +36,7 @@ interface Callbacks { const XMLRPC_CALLBACKHELP = 'XmlRpc.CallbackHelp'; const XMLRPC_METHODSLIST = 'XmlRpc.MethodsList'; const XMLRPC_METHODHELP = 'XmlRpc.MethodHelp'; - const XMLRPC_DOCUMENTATION = 'XmlRpc.MethodHelp'; + const XMLRPC_DOCUMENTATION = 'XmlRpc.Documentation'; const XMLRPC_APIVERSION = 'XmlRpc.ApiVersion'; const XMLRPC_ALLAPIVERSIONS = 'XmlRpc.AllApiVersions'; diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index aedf6bb8..919cd7d3 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -9,7 +9,13 @@ use ManiaControl\Callbacks\Structures\ManiaPlanet\StartServerStructure; use ManiaControl\Callbacks\Structures\NearMissStructure; use ManiaControl\Callbacks\Structures\PlayerHitStructure; use ManiaControl\Callbacks\Structures\ShootMania\StatusCallbackStructure; -use ManiaControl\Callbacks\Structures\XmlRpc\ListStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\AllApiVersionsStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\ApiVersionStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\CallbackHelpStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\CallbackListStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\DocumentationStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\MethodHelpStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\MethodListStructure; use ManiaControl\ManiaControl; /** @@ -51,40 +57,43 @@ class LibXmlRpcCallbacks implements CallbackListener { switch ($name) { //New callbacks case Callbacks::XMLRPC_CALLBACKSLIST: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new ListStructure($this->maniaControl, $data)); - break; case Callbacks::XMLRPC_ENABLEDCALLBACKS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_ENABLEDCALLBACKS, new ListStructure($this->maniaControl, $data)); - break; case Callbacks::XMLRPC_DISABLEDCALLBACKS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_DISABLEDCALLBACKS, new ListStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new CallbackListStructure($this->maniaControl, $data)); + break; + case Callbacks::XMLRPC_CALLBACKHELP: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new CallbackHelpStructure($this->maniaControl, $data)); break; case Callbacks::XMLRPC_APIVERSION: - //TODO + $this->maniaControl->getCallbackManager()->triggerCallback($name, new ApiVersionStructure($this->maniaControl, $data)); break; case Callbacks::XMLRPC_ALLAPIVERSIONS: - //TODO + $this->maniaControl->getCallbackManager()->triggerCallback($name, new AllApiVersionsStructure($this->maniaControl, $data)); break; case Callbacks::XMLRPC_DOCUMENTATION: - //TODO + $this->maniaControl->getCallbackManager()->triggerCallback($name, new DocumentationStructure($this->maniaControl, $data)); break; case Callbacks::XMLRPC_METHODSLIST: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_METHODSLIST, new ListStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new MethodListStructure($this->maniaControl, $data)); break; case Callbacks::XMLRPC_METHODHELP: - //TODO - break; - case Callbacks::MP_STARTSERVERSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_STARTSERVEREND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVEREND, new StartServerStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_STARTMATCHSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHSTART, new StartEndStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new MethodHelpStructure($this->maniaControl, $data)); break; case Callbacks::MP_STARTMATCHEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHEND, new StartEndStructure($this->maniaControl, $data)); + case Callbacks::MP_STARTMATCHSTART: + case Callbacks::MP_STARTROUNDSTART: + case Callbacks::MP_STARTROUNDEND: + case Callbacks::MP_STARTTURNSTART: + case Callbacks::MP_STARTTURNEND: + case Callbacks::MP_STARTPLAYLOOP: + case Callbacks::MP_ENDPLAYLOOP: + case Callbacks::MP_ENDTURNSTART: + case Callbacks::MP_ENDTURNEND: + case Callbacks::MP_ENDROUNDSTART: + case Callbacks::MP_ENDROUNDEND: + case Callbacks::MP_ENDMATCHSTART: + case Callbacks::MP_ENDMATCHEND: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new StartEndStructure($this->maniaControl, $data)); break; case 'Maniaplanet.StartMap_Start': //Use the MapManager Callback //No use for this Implementation right now (as the MapManager Callback should be used @@ -94,84 +103,34 @@ class LibXmlRpcCallbacks implements CallbackListener { $this->maniaControl->getMapManager()->handleScriptBeginMap($jsonData->map->uid, 'False'); //TODO Test if json is correctly parsed break; - case Callbacks::MP_STARTROUNDSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDSTART, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_STARTROUNDEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDEND, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_STARTTURNSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNSTART, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_STARTTURNEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNEND, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_STARTPLAYLOOP: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOP, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_ENDPLAYLOOP: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDPLAYLOOP, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_ENDTURNSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNSTART, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_ENDTURNEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNEND, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_ENDROUNDSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDSTART, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_ENDROUNDEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDEND, new StartEndStructure($this->maniaControl, $data)); - break; case 'Maniaplanet.EndMap_Start': //no need for this implementation, callback handled by Map Manager break; case 'Maniaplanet.EndMap_End': //Use the MapManager Callback $this->maniaControl->getMapManager()->handleScriptEndMap(); //Verify if better here or at EndMap_End break; - case Callbacks::MP_ENDMATCHSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHSTART, new StartEndStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_ENDMATCHEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHEND, new StartEndStructure($this->maniaControl, $data)); - break; + case Callbacks::MP_STARTSERVERSTART: + case Callbacks::MP_STARTSERVEREND: case Callbacks::MP_ENDSERVERSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVERSTART, new StartServerStructure($this->maniaControl, $data)); - break; case Callbacks::MP_ENDSERVEREND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVEREND, new StartServerStructure($this->maniaControl, $data)); - break; - case Callbacks::MP_LOADINGMAPSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPSTART); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new StartServerStructure($this->maniaControl, $data)); break; case Callbacks::MP_LOADINGMAPEND: - $jsonData = json_decode($data[0]); - $map = $this->maniaControl->getMapManager()->getMapByUid($jsonData->map->uid); //Verify Json - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPEND, $map); - break; case Callbacks::MP_UNLOADINGMAPSTART: $jsonData = json_decode($data[0]); $map = $this->maniaControl->getMapManager()->getMapByUid($jsonData->map->uid); //Verify Json - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPSTART, $map); + $this->maniaControl->getCallbackManager()->triggerCallback($name, $map); break; + case Callbacks::MP_LOADINGMAPSTART: case Callbacks::MP_UNLOADINGMAPEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPEND); - break; case Callbacks::MP_PODIUMSTART: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMSTART); - break; case Callbacks::MP_PODIUMEND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMEND); - break; case Callbacks::MP_WARMUP_START: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_WARMUP_START); - break; case Callbacks::MP_WARMUP_END: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_WARMUP_END); + $this->maniaControl->getCallbackManager()->triggerCallback($name); break; case Callbacks::MP_WARMUP_STATUS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_WARMUP_STATUS, new StatusCallbackStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new StatusCallbackStructure($this->maniaControl, $data)); break; //OLD Callbacks diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index c7ac4923..237d1d9b 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -78,82 +78,82 @@ class ShootManiaCallbacks implements CallbackListener { switch ($name) { //MP4 New Callbacks case Callbacks::SM_SCORES: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_SCORES, new OnScoresStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnScoresStructure($this->maniaControl, $data)); break; case Callbacks::SM_UIPROPERTIES: //TODO break; case Callbacks::SM_ONEVENTDEFAULT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnDefaultEventStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONSHOOT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOOT, new OnShootStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnShootStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONHIT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONHIT, new OnHitStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnHitStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONNEARMISS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONNEARMISS, new OnNearMissStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnNearMissStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONARMOREMPTY: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONARMOREMPTY, new OnArmorEmptyStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnArmorEmptyStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONCAPTURE: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnCaptureStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONSHOTDENY: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOTDENY, new OnShotDenyStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnShotDenyStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONCOMMAND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCOMMAND, new OnCommandStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnCommandStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONPLAYERREQUESTRESPAWN: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTRESPAWN, new OnPlayerRequestRespawnStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayerRequestRespawnStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONACTIONCUSTOMEVENT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONACTIONCUSTOMEVENT, new OnActionCustomEventStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnActionCustomEventStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONACTIONEVENT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONACTIONEVENT, new OnActionEvent($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnActionEvent($this->maniaControl, $data)); break; case Callbacks::SM_ONPLAYERTOUCHESOBJECT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTOUCHESOBJECT, new OnPlayerObjectStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayerObjectStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONPLAYERTRIGGERSSECTOR: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTRIGGERSSECTOR, new OnPlayerTriggersSectorStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayerTriggersSectorStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONPLAYERTHROWSOBJECT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTHROWSOBJECT, new OnPlayerObjectStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayerObjectStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayerRequestActionChange($this->maniaControl, $data)); break; case Callbacks::SM_COMBO_PAUSESTATUS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_COMBO_PAUSESTATUS, new StatusCallbackStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new StatusCallbackStructure($this->maniaControl, $data)); break; case Callbacks::SM_ELITE_STARTTURN: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ELITE_STARTTURN, new OnEliteStartTurnStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEliteStartTurnStructure($this->maniaControl, $data)); break; case Callbacks::SM_ELITE_ENDTURN: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ELITE_ENDTURN, new OnEliteEndTurnStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEliteEndTurnStructure($this->maniaControl, $data)); break; case Callbacks::SM_JOUST_ONRELOAD: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_JOUST_ONRELOAD, new OnJoustReloadStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnJoustReloadStructure($this->maniaControl, $data)); break; case Callbacks::SM_JOUST_SELECTEDPLAYERS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_JOUST_SELECTEDPLAYERS, new OnJoustSelectedPlayersStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnJoustSelectedPlayersStructure($this->maniaControl, $data)); break; case Callbacks::SM_JOUST_ROUNDRESULT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_JOUST_ROUNDRESULT, new OnJoustRoundResultsStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnJoustRoundResultsStructure($this->maniaControl, $data)); break; case Callbacks::SM_ROYAL_POINTS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ROYAL_POINTS, new OnRoyalPointsStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRoyalPointsStructure($this->maniaControl, $data)); break; case Callbacks::SM_ROYAL_PLAYERSPAWN: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ROYAL_PLAYERSPAWN, new OnRoyalPlayerSpawnStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRoyalPlayerSpawnStructure($this->maniaControl, $data)); break; case Callbacks::SM_ROYAL_ROUNDWINNER: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ROYAL_ROUNDWINNER, new OnRoyalRoundWinnerStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRoyalRoundWinnerStructure($this->maniaControl, $data)); break; //Old Callbacks diff --git a/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php b/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php new file mode 100644 index 00000000..ab320f24 --- /dev/null +++ b/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php @@ -0,0 +1,54 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class AllApiVersionsStructure extends BaseResponseStructure { + private $latest; + private $versions; + + /** + * Construct a new Callbacks Version Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->latest = $this->getPlainJsonObject()->latest; + $this->versions = $this->getPlainJsonObject()->versions; + } + + /** + * Get the Latest Version + * + * @api + * @return string + */ + public function getLatest() { + return $this->latest; + } + + /** + * Get all Versions + * + * @api + * @return array + */ + public function getVersions() { + return $this->versions; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php b/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php new file mode 100644 index 00000000..2c34bb40 --- /dev/null +++ b/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php @@ -0,0 +1,41 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class ApiVersionStructure extends BaseResponseStructure { + private $version; + + /** + * Construct a new Callbacks Version Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->version = $this->getPlainJsonObject()->version; + } + + /** + * Gets the API Version + * + * @api + * @return string version + */ + public function getVersion() { + return $this->version; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php b/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php new file mode 100644 index 00000000..23230721 --- /dev/null +++ b/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php @@ -0,0 +1,40 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class CallbackHelpStructure extends DocumentationStructure { + private $callbackName; + + /** + * Construct a new Callbacks List Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->callbackName = $this->getPlainJsonObject()->callback; + } + + /** + * Gets the Name of the Method + * + * @api + * @return mixed + */ + public function getMethodName() { + return $this->callbackName; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/ListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbackListStructure.php similarity index 82% rename from core/Callbacks/Structures/XmlRpc/ListStructure.php rename to core/Callbacks/Structures/XmlRpc/CallbackListStructure.php index 25cca84e..3d9d0a33 100644 --- a/core/Callbacks/Structures/XmlRpc/ListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbackListStructure.php @@ -3,17 +3,17 @@ namespace ManiaControl\Callbacks\Structures\XmlRpc; use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; use ManiaControl\ManiaControl; /** * Structure Class for the List Structure Callback * + * @api * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ListStructure extends BaseResponseStructure { +class CallbackListStructure extends BaseResponseStructure { /** @var array $callbacks */ private $callbacks; @@ -26,13 +26,14 @@ class ListStructure extends BaseResponseStructure { public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); - $this->callbacks = $this->getPlainJsonObject()->callbacks; + $this->callbacks = $this->getPlainJsonObject()->callbacks; } /** * Get Array of the Callbacks * + * @api * @return string[] */ public function getCallbacks() { diff --git a/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php b/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php new file mode 100644 index 00000000..2e1defd1 --- /dev/null +++ b/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php @@ -0,0 +1,42 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class DocumentationStructure extends BaseResponseStructure { + private $documentation; + + /** + * Construct a new Callbacks List Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->documentation = $data[1]; + } + + /** + * Gets the Documentation + * + * @api + * @return string + */ + public function getDocumentation() { + return $this->documentation; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php b/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php new file mode 100644 index 00000000..ae4317b7 --- /dev/null +++ b/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php @@ -0,0 +1,40 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class MethodHelpStructure extends DocumentationStructure { + private $methodName; + + /** + * Construct a new Callbacks List Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->methodName = $this->getPlainJsonObject()->method; + } + + /** + * Gets the Name of the Method + * + * @api + * @return mixed + */ + public function getMethodName() { + return $this->methodName; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/MethodListStructure.php b/core/Callbacks/Structures/XmlRpc/MethodListStructure.php new file mode 100644 index 00000000..0f50abb3 --- /dev/null +++ b/core/Callbacks/Structures/XmlRpc/MethodListStructure.php @@ -0,0 +1,43 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class MethodListStructure extends BaseResponseStructure { + /** @var array $callbacks */ + private $methods; + + /** + * Construct a new Callbacks List Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->methods = $this->getPlainJsonObject()->methods; + } + + + /** + * Get Array of the Methods + * + * @api + * @return string[] + */ + public function getMethods() { + return $this->methods; + } + +} \ No newline at end of file diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index 298bbe2e..e83cff75 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -3,11 +3,11 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; +use ManiaControl\Callbacks\Structures\TrackMania\OnCommandStructure; use ManiaControl\Callbacks\Structures\TrackMania\OnDefaultEventStructure; use ManiaControl\Callbacks\Structures\TrackMania\OnEventStartLineStructure; -use ManiaControl\Callbacks\Structures\TrackMania\OnCommandStructure; -use ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure; use ManiaControl\Callbacks\Structures\TrackMania\OnEventWayPointStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure; use ManiaControl\ManiaControl; use ManiaControl\Utils\Formatter; @@ -52,23 +52,23 @@ class TrackManiaCallbacks implements CallbackListener { switch ($name) { //MP4 New Callbacks case Callbacks::TM_SCORES: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_SCORES, new OnScoresStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnScoresStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONEVENTDEFAULT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnDefaultEventStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONEVENTSTARTLINE: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONEVENTSTARTLINE, new OnEventStartLineStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEventStartLineStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONCOMMAND: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONCOMMAND, new OnCommandStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnCommandStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONPLAYERADDED: break; case Callbacks::TM_ONPLAYERREMOVED: break; case Callbacks::TM_ONWAYPOINT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONWAYPOINT, new OnEventWayPointStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEventWayPointStructure($this->maniaControl, $data)); break; case Callbacks:: TM_ONGIVEUP: break; diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index adca2679..1c7cd59d 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -3,6 +3,7 @@ namespace ManiaControl\Script; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\Callbacks\Structures\XmlRpc\DocumentationStructure; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl;