From b96c3e92fd499e8e8c13b1650254a25ffa9023a4 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 24 Mar 2017 16:49:54 +0100 Subject: [PATCH] added two new callbacks --- core/Callbacks/Callbacks.php | 3 ++- core/Callbacks/LibXmlRpcCallbacks.php | 9 ++++++++- core/Callbacks/Structures/BaseStructure.php | 13 +++++++------ .../ManiaPlanet/StartServerStructure.php | 16 ++++++++++++++++ .../Structures/XmlRpc/CallbacksListStructure.php | 4 ++-- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index df8cc2bb..579b8245 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -31,7 +31,8 @@ interface Callbacks { //NEW Callbacks const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; - + const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; + const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerStart'; //OLD Callbacks /** BeginMatch Callback: MatchNumber */ diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index d9bd2ee1..b5d74751 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -4,9 +4,10 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Structures\ArmorEmptyStructure; use ManiaControl\Callbacks\Structures\CaptureStructure; -use ManiaControl\Callbacks\Structures\XmlRpc\CallbacksListStructure; +use ManiaControl\Callbacks\Structures\ManiaPlanet\StartServerStructure; use ManiaControl\Callbacks\Structures\NearMissStructure; use ManiaControl\Callbacks\Structures\PlayerHitStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\CallbacksListStructure; use ManiaControl\ManiaControl; /** @@ -49,6 +50,12 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'XmlRpc.CallbacksList': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); break; + case 'Maniaplanet.StartServer_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data)); + break; + case 'Maniaplanet.StartServer_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVEREND, new StartServerStructure($this->maniaControl, $data)); + break; //OLD Callbacks case 'LibXmlRpc_BeginMatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 75bd7393..f66dbb21 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -1,16 +1,17 @@ + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ abstract class BaseStructure { /** @var ManiaControl $maniaControl */ protected $maniaControl; diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php index 89461340..654c08a7 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -6,10 +6,26 @@ namespace ManiaControl\Callbacks\Structures\ManiaPlanet; use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\ManiaControl; +/** + * Structure Class for the Default Start Server Callback + * + * @author ManiaControl Team + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ class StartServerStructure extends BaseStructure { + public $restarted; + public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); + $this->restarted = $this->getPlainJsonObject()->restarted; + } + /** + * @return mixed + */ + public function getRestarted() { + return $this->restarted; } } \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index c4f815c8..71734037 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -27,8 +27,8 @@ class CallbacksListStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); - $this->responseId = $this->getJson()->responseid; - $this->callbacks = $this->getJson()->callbacks; + $this->responseId = $this->getPlainJsonObject()->responseid; + $this->callbacks = $this->getPlainJsonObject()->callbacks; } /**