added two new callbacks

This commit is contained in:
kremsy 2017-03-24 16:49:54 +01:00
parent 49cc190b86
commit b96c3e92fd
5 changed files with 35 additions and 10 deletions

View File

@ -31,7 +31,8 @@ interface Callbacks {
//NEW Callbacks //NEW Callbacks
const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList';
const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart';
const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerStart';
//OLD Callbacks //OLD Callbacks
/** BeginMatch Callback: MatchNumber */ /** BeginMatch Callback: MatchNumber */

View File

@ -4,9 +4,10 @@ namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Structures\ArmorEmptyStructure; use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\CaptureStructure; 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\NearMissStructure;
use ManiaControl\Callbacks\Structures\PlayerHitStructure; use ManiaControl\Callbacks\Structures\PlayerHitStructure;
use ManiaControl\Callbacks\Structures\XmlRpc\CallbacksListStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/** /**
@ -49,6 +50,12 @@ class LibXmlRpcCallbacks implements CallbackListener {
case 'XmlRpc.CallbacksList': case 'XmlRpc.CallbacksList':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data));
break; 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 //OLD Callbacks
case 'LibXmlRpc_BeginMatch': case 'LibXmlRpc_BeginMatch':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]);

View File

@ -1,16 +1,17 @@
<?php <?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 22. Mär. 2017
* Time: 18:26
*/
namespace ManiaControl\Callbacks\Structures; namespace ManiaControl\Callbacks\Structures;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/**
* Base Structure of all Callback Structures
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class BaseStructure { abstract class BaseStructure {
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
protected $maniaControl; protected $maniaControl;

View File

@ -6,10 +6,26 @@ namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/**
* Structure Class for the Default Start Server Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class StartServerStructure extends BaseStructure { class StartServerStructure extends BaseStructure {
public $restarted;
public function __construct(ManiaControl $maniaControl, $data) { public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data); parent::__construct($maniaControl, $data);
$this->restarted = $this->getPlainJsonObject()->restarted;
}
/**
* @return mixed
*/
public function getRestarted() {
return $this->restarted;
} }
} }

View File

@ -27,8 +27,8 @@ class CallbacksListStructure extends BaseStructure {
public function __construct(ManiaControl $maniaControl, $data) { public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data); parent::__construct($maniaControl, $data);
$this->responseId = $this->getJson()->responseid; $this->responseId = $this->getPlainJsonObject()->responseid;
$this->callbacks = $this->getJson()->callbacks; $this->callbacks = $this->getPlainJsonObject()->callbacks;
} }
/** /**