callback implementation
This commit is contained in:
		| @@ -63,7 +63,7 @@ interface Callbacks { | |||||||
|  |  | ||||||
| 	const SM_SCORES = "Shootmania.Scores"; | 	const SM_SCORES = "Shootmania.Scores"; | ||||||
|  |  | ||||||
| 	const SM_EVENTDEFAULT = "Shootmania.Event.Default"; | 	const SM_ONEVENTDEFAULT = "Shootmania.Event.Default"; | ||||||
| 	const SM_ONSHOOT        = "Shootmania.Event.OnShoot"; | 	const SM_ONSHOOT        = "Shootmania.Event.OnShoot"; | ||||||
| 	const SM_ONHIT          = "Shootmania.Event.OnHit"; | 	const SM_ONHIT          = "Shootmania.Event.OnHit"; | ||||||
| 	const SM_ONNEARMISS     = "Shootmania.Event.OnNearMiss"; | 	const SM_ONNEARMISS     = "Shootmania.Event.OnNearMiss"; | ||||||
| @@ -73,7 +73,7 @@ interface Callbacks { | |||||||
| 	const SM_ONFALLDAMAGE   = "Shootmania.Event.OnFallDamage"; | 	const SM_ONFALLDAMAGE   = "Shootmania.Event.OnFallDamage"; | ||||||
| 	const SM_ONCOMMAND      = "Shootmania.Event.OnCommand"; | 	const SM_ONCOMMAND      = "Shootmania.Event.OnCommand"; | ||||||
| 	//Shootmania.Event.OnPlayerRemoved Shootmania.Event.OnPlayerAdded not needed yet | 	//Shootmania.Event.OnPlayerRemoved Shootmania.Event.OnPlayerAdded not needed yet | ||||||
| 	const SM_ONPLAYERREQUESTRESAWPN      = "Shootmania.Event.OnPlayerRequestRespawn"; | 	const SM_ONPLAYERREQUESTRESPAWN      = "Shootmania.Event.OnPlayerRequestRespawn"; | ||||||
| 	const SM_ONACTIONCUSTOMEVENT         = "Shootmania.Event.OnActionCustomEvent"; | 	const SM_ONACTIONCUSTOMEVENT         = "Shootmania.Event.OnActionCustomEvent"; | ||||||
| 	const SM_ONACTIONEVENT               = "Shootmania.Event.OnActionEvent"; | 	const SM_ONACTIONEVENT               = "Shootmania.Event.OnActionEvent"; | ||||||
| 	const SM_ONPLAYERTOUCHESOBJECT       = "Shootmania.Event.OnPlayerTouchesObject"; | 	const SM_ONPLAYERTOUCHESOBJECT       = "Shootmania.Event.OnPlayerTouchesObject"; | ||||||
| @@ -82,7 +82,7 @@ interface Callbacks { | |||||||
| 	const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; | 	const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	const TM_EVENTDEFAULT = "Trackmania.Event.Default"; | 	const TM_ONEVENTDEFAULT = "Trackmania.Event.Default"; | ||||||
|  |  | ||||||
| 	//ManiaControl Callbacks | 	//ManiaControl Callbacks | ||||||
| 	/** BeginMap Callback: Map */ | 	/** BeginMap Callback: Map */ | ||||||
|   | |||||||
| @@ -46,7 +46,7 @@ class LibXmlRpcCallbacks implements CallbackListener { | |||||||
| 	public function handleScriptCallback($name, $data) { | 	public function handleScriptCallback($name, $data) { | ||||||
| 		var_dump($name); | 		var_dump($name); | ||||||
| 		if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { | 		if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { | ||||||
| 			return; | 			//return; //Leave that disabled while testing/implementing Callbacks | ||||||
| 		} | 		} | ||||||
| 		switch ($name) { | 		switch ($name) { | ||||||
| 			//New callbacks | 			//New callbacks | ||||||
|   | |||||||
| @@ -4,10 +4,13 @@ namespace ManiaControl\Callbacks; | |||||||
|  |  | ||||||
| use ManiaControl\Callbacks\Models\RecordCallback; | use ManiaControl\Callbacks\Models\RecordCallback; | ||||||
| use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; | use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; | ||||||
| use ManiaControl\Callbacks\Structures\ShootMania\DefaultEventStructure; |  | ||||||
| use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; | use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; | ||||||
|  | use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure; | ||||||
|  | use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure; | ||||||
| use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; | use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; | ||||||
|  | use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure; | ||||||
| use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; | use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; | ||||||
|  | use ManiaControl\Callbacks\Structures\ShootMania\OnShotDenyStructure; | ||||||
| use ManiaControl\ManiaControl; | use ManiaControl\ManiaControl; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -53,12 +56,12 @@ class ShootManiaCallbacks implements CallbackListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function handleScriptCallbacks($name, $data) { | 	public function handleScriptCallbacks($name, $data) { | ||||||
| 		if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { | 		if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { | ||||||
| 			return; | 			//return; //Leave that disabled while testing/implementing Callbacks | ||||||
| 		} | 		} | ||||||
| 		switch ($name) { | 		switch ($name) { | ||||||
| 			//MP4 New Callbacks | 			//MP4 New Callbacks | ||||||
| 			case Callbacks::SM_EVENTDEFAULT: | 			case Callbacks::SM_ONEVENTDEFAULT: | ||||||
| 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_EVENTDEFAULT, new DefaultEventStructure($this->maniaControl, $data)); | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); | ||||||
| 				break; | 				break; | ||||||
| 			case Callbacks::SM_ONSHOOT: | 			case Callbacks::SM_ONSHOOT: | ||||||
| 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOOT, new OnShootStructure($this->maniaControl, $data)); | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOOT, new OnShootStructure($this->maniaControl, $data)); | ||||||
| @@ -75,6 +78,17 @@ class ShootManiaCallbacks implements CallbackListener { | |||||||
| 			case Callbacks::SM_ONCAPTURE: | 			case Callbacks::SM_ONCAPTURE: | ||||||
| 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data)); | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data)); | ||||||
| 				break; | 				break; | ||||||
|  | 			case Callbacks::SM_ONSHOTDENY: | ||||||
|  | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOTDENY, new OnShotDenyStructure($this->maniaControl, $data)); | ||||||
|  | 				break; | ||||||
|  | 			case Callbacks::SM_ONCOMMAND: | ||||||
|  | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCOMMAND, new OnCommandStructure($this->maniaControl, $data)); | ||||||
|  | 				break; | ||||||
|  | 			case Callbacks::SM_ONPLAYERREQUESTRESPAWN: | ||||||
|  | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTRESPAWN, new OnPlayerRequestRespawnStructure($this->maniaControl, $data)); | ||||||
|  | 				break; | ||||||
|  | 			case Callbacks::SM_ONACTIONCUSTOMEVENT: | ||||||
|  | 				break; | ||||||
| 			//Old Callbacks | 			//Old Callbacks | ||||||
| 			case 'LibXmlRpc_Rankings': | 			case 'LibXmlRpc_Rankings': | ||||||
| 				$this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]); | 				$this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]); | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| <?php | <?php | ||||||
| /** |  | ||||||
|  * Created by PhpStorm. |  | ||||||
|  * User: Lukas |  | ||||||
|  * Date: 25. Mär. 2017 |  | ||||||
|  * Time: 11:37 |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,14 +1,8 @@ | |||||||
| <?php | <?php | ||||||
| /** |  | ||||||
|  * Created by PhpStorm. |  | ||||||
|  * User: Lukas |  | ||||||
|  * Date: 25. Mär. 2017 |  | ||||||
|  * Time: 12:44 |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | ||||||
|  |  | ||||||
|  | //TODO describtion | ||||||
| class PlayerScore { | class PlayerScore { | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -3,7 +3,7 @@ | |||||||
|  |  | ||||||
| namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | ||||||
|  |  | ||||||
|  | //TODO describtion | ||||||
| class Position { | class Position { | ||||||
| 	private $x = 0; | 	private $x = 0; | ||||||
| 	private $y = 0; | 	private $y = 0; | ||||||
|   | |||||||
| @@ -1,14 +1,8 @@ | |||||||
| <?php | <?php | ||||||
| /** |  | ||||||
|  * Created by PhpStorm. |  | ||||||
|  * User: Lukas |  | ||||||
|  * Date: 25. Mär. 2017 |  | ||||||
|  * Time: 12:43 |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | ||||||
|  |  | ||||||
|  | //TODO describtion | ||||||
| class TeamScore { | class TeamScore { | ||||||
| 	private $id; | 	private $id; | ||||||
| 	private $name; | 	private $name; | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								core/Callbacks/Structures/ShootMania/Models/Weapons.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								core/Callbacks/Structures/ShootMania/Models/Weapons.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\ShootMania\Models; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Weapons Interface | ||||||
|  |  * | ||||||
|  |  * @author    ManiaControl Team <mail@maniacontrol.com> | ||||||
|  |  * @copyright 2014-2017 ManiaControl Team | ||||||
|  |  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||||
|  |  */ | ||||||
|  | interface Weapons { | ||||||
|  | 	const LASER   = 1; | ||||||
|  | 	const ROCKET  = 2; | ||||||
|  | 	const NUCLEUS = 3; | ||||||
|  | 	const ARROW   = 5; | ||||||
|  | } | ||||||
							
								
								
									
										57
									
								
								core/Callbacks/Structures/ShootMania/OnCommandStructure.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								core/Callbacks/Structures/ShootMania/OnCommandStructure.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\ShootMania; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use ManiaControl\Callbacks\Structures\BaseStructure; | ||||||
|  | use ManiaControl\ManiaControl; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Structure Class for the OnCommand Structure 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 OnCommandStructure extends BaseStructure { | ||||||
|  | 	public $time; | ||||||
|  | 	public $name; | ||||||
|  | 	public $value; | ||||||
|  |  | ||||||
|  | 	public function __construct(ManiaControl $maniaControl, $data) { | ||||||
|  | 		parent::__construct($maniaControl, $data); | ||||||
|  |  | ||||||
|  | 		$this->time  = $this->getPlainJsonObject()->time; | ||||||
|  | 		$this->name  = $this->getPlainJsonObject()->name; | ||||||
|  | 		$this->value = $this->getPlainJsonObject()->value; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** Dumps the Object with some Information */ | ||||||
|  | 	public function dump() { | ||||||
|  | 		parent::dump(); | ||||||
|  | 		var_dump("With getShooter() you get a Player Object"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
|  | 	public function getTime() { | ||||||
|  | 		return $this->time; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return mixed | ||||||
|  | 	 */ | ||||||
|  | 	public function getName() { | ||||||
|  | 		return $this->name; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return \ManiaControl\Players\Player | ||||||
|  | 	 */ | ||||||
|  | 	public function getValue() { | ||||||
|  | 		return $this->value; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,14 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * Created by PhpStorm. | ||||||
|  |  * User: Lukas | ||||||
|  |  * Date: 25. Mär. 2017 | ||||||
|  |  * Time: 19:53 | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\ShootMania; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class OnCustomEventStructure { | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; | |||||||
|  * @copyright 2014-2017 ManiaControl Team |  * @copyright 2014-2017 ManiaControl Team | ||||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 |  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||||
|  */ |  */ | ||||||
| class DefaultEventStructure extends BaseStructure { | class OnDefaultEventStructure extends BaseStructure { | ||||||
| 	public $time; | 	public $time; | ||||||
| 	public $type; | 	public $type; | ||||||
| 
 | 
 | ||||||
| @@ -0,0 +1,50 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\ShootMania; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use ManiaControl\Callbacks\Structures\BaseStructure; | ||||||
|  | use ManiaControl\ManiaControl; | ||||||
|  | use ManiaControl\Players\Player; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Structure Class for the OnFallDamage Structure 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 OnFallDamageStructure extends BaseStructure { | ||||||
|  | 	public $time; | ||||||
|  | 	/** | ||||||
|  | 	 * @var Player $shooter | ||||||
|  | 	 */ | ||||||
|  | 	private $victim; | ||||||
|  |  | ||||||
|  | 	public function __construct(ManiaControl $maniaControl, $data) { | ||||||
|  | 		parent::__construct($maniaControl, $data); | ||||||
|  |  | ||||||
|  | 		$this->time   = $this->getPlainJsonObject()->time; | ||||||
|  | 		$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
|  | 	public function getTime() { | ||||||
|  | 		return $this->time; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return Player | ||||||
|  | 	 */ | ||||||
|  | 	public function getVictim() { | ||||||
|  | 		return $this->victim; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** Dumps the Object with some Information */ | ||||||
|  | 	public function dump() { | ||||||
|  | 		parent::dump(); | ||||||
|  | 		var_dump("With getVictim() you get a Player Object"); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -0,0 +1,50 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\ShootMania; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use ManiaControl\Callbacks\Structures\BaseStructure; | ||||||
|  | use ManiaControl\ManiaControl; | ||||||
|  | use ManiaControl\Players\Player; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Structure Class for the OnPlayerRequestRespawnStructure Structure 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 OnPlayerRequestRespawnStructure extends BaseStructure { | ||||||
|  | 	public $time; | ||||||
|  | 	/** | ||||||
|  | 	 * @var Player $shooter | ||||||
|  | 	 */ | ||||||
|  | 	private $player; | ||||||
|  |  | ||||||
|  | 	public function __construct(ManiaControl $maniaControl, $data) { | ||||||
|  | 		parent::__construct($maniaControl, $data); | ||||||
|  |  | ||||||
|  | 		$this->time   = $this->getPlainJsonObject()->time; | ||||||
|  | 		$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
|  | 	public function getTime() { | ||||||
|  | 		return $this->time; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return Player | ||||||
|  | 	 */ | ||||||
|  | 	public function getPlayer() { | ||||||
|  | 		return $this->player; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** Dumps the Object with some Information */ | ||||||
|  | 	public function dump() { | ||||||
|  | 		parent::dump(); | ||||||
|  | 		var_dump("With getPlayer() you get a Player Object"); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -7,6 +7,13 @@ use ManiaControl\Callbacks\Structures\BaseStructure; | |||||||
| use ManiaControl\ManiaControl; | use ManiaControl\ManiaControl; | ||||||
| use ManiaControl\Players\Player; | use ManiaControl\Players\Player; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Structure Class for the OnShoot Structure 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 OnShootStructure extends BaseStructure { | class OnShootStructure extends BaseStructure { | ||||||
| 	public $time; | 	public $time; | ||||||
| 	public $weapon; | 	public $weapon; | ||||||
| @@ -15,7 +22,6 @@ class OnShootStructure extends BaseStructure { | |||||||
| 	 */ | 	 */ | ||||||
| 	private $shooter; | 	private $shooter; | ||||||
|  |  | ||||||
| 	//TODO test |  | ||||||
| 	public function __construct(ManiaControl $maniaControl, $data) { | 	public function __construct(ManiaControl $maniaControl, $data) { | ||||||
| 		parent::__construct($maniaControl, $data); | 		parent::__construct($maniaControl, $data); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										88
									
								
								core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\ShootMania; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use ManiaControl\Callbacks\Structures\BaseStructure; | ||||||
|  | use ManiaControl\ManiaControl; | ||||||
|  | use ManiaControl\Players\Player; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Structure Class for the OnShotDeny Structure 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 OnShotDenyStructure extends BaseStructure { | ||||||
|  | 	public $time; | ||||||
|  | 	public $shooterWeapon; | ||||||
|  | 	public $victimWeapon; | ||||||
|  |  | ||||||
|  | 	protected $shooter; | ||||||
|  | 	protected $victim; | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Construct a new On Hit Structure | ||||||
|  | 	 * | ||||||
|  | 	 * @param ManiaControl $maniaControl | ||||||
|  | 	 * @param array        $data | ||||||
|  | 	 */ | ||||||
|  | 	public function __construct(ManiaControl $maniaControl, $data) { | ||||||
|  | 		parent::__construct($maniaControl, $data); | ||||||
|  |  | ||||||
|  | 		$jsonObj             = $this->getPlainJsonObject(); | ||||||
|  | 		$this->time          = $jsonObj->time; | ||||||
|  | 		$this->shooterWeapon = $jsonObj->victim; | ||||||
|  | 		$this->victimWeapon  = $jsonObj->damage; | ||||||
|  |  | ||||||
|  | 		$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); | ||||||
|  | 		$this->victim  = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** Dumps the Object with some Information */ | ||||||
|  | 	public function dump() { | ||||||
|  | 		parent::dump(); | ||||||
|  | 		var_dump("With getShooter() you get a Player Object"); | ||||||
|  | 		var_dump("With getVictim() you get a Player Object"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
|  | 	public function getTime() { | ||||||
|  | 		return $this->time; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return Player | ||||||
|  | 	 */ | ||||||
|  | 	public function getShooter() { | ||||||
|  | 		return $this->shooter; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return Player | ||||||
|  | 	 */ | ||||||
|  | 	public function getVictim() { | ||||||
|  | 		return $this->victim; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return mixed | ||||||
|  | 	 */ | ||||||
|  | 	public function getShooterWeapon() { | ||||||
|  | 		return $this->shooterWeapon; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return mixed | ||||||
|  | 	 */ | ||||||
|  | 	public function getVictimWeapon() { | ||||||
|  | 		return $this->victimWeapon; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										57
									
								
								core/Callbacks/Structures/TrackMania/OnCommandStructure.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								core/Callbacks/Structures/TrackMania/OnCommandStructure.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Callbacks\Structures\TrackMania; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use ManiaControl\Callbacks\Structures\BaseStructure; | ||||||
|  | use ManiaControl\ManiaControl; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Structure Class for the OnCommand Structure 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 OnCommandStructure extends BaseStructure { | ||||||
|  | 	public $time; | ||||||
|  | 	public $name; | ||||||
|  | 	public $value; | ||||||
|  |  | ||||||
|  | 	public function __construct(ManiaControl $maniaControl, $data) { | ||||||
|  | 		parent::__construct($maniaControl, $data); | ||||||
|  |  | ||||||
|  | 		$this->time  = $this->getPlainJsonObject()->time; | ||||||
|  | 		$this->name  = $this->getPlainJsonObject()->name; | ||||||
|  | 		$this->value = $this->getPlainJsonObject()->value; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** Dumps the Object with some Information */ | ||||||
|  | 	public function dump() { | ||||||
|  | 		parent::dump(); | ||||||
|  | 		var_dump("With getShooter() you get a Player Object"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
|  | 	public function getTime() { | ||||||
|  | 		return $this->time; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return mixed | ||||||
|  | 	 */ | ||||||
|  | 	public function getName() { | ||||||
|  | 		return $this->name; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @return \ManiaControl\Players\Player | ||||||
|  | 	 */ | ||||||
|  | 	public function getValue() { | ||||||
|  | 		return $this->value; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace ManiaControl\Callbacks\Structures\Trackmania; | namespace ManiaControl\Callbacks\Structures\TrackMania; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| use ManiaControl\Callbacks\Structures\BaseStructure; | use ManiaControl\Callbacks\Structures\BaseStructure; | ||||||
| @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; | |||||||
|  * @copyright 2014-2017 ManiaControl Team |  * @copyright 2014-2017 ManiaControl Team | ||||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 |  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||||
|  */ |  */ | ||||||
| class DefaultEventStructure extends BaseStructure { | class OnDefaultEventStructure extends BaseStructure { | ||||||
| 	public $time; | 	public $time; | ||||||
| 	public $type; | 	public $type; | ||||||
| 
 | 
 | ||||||
| @@ -3,7 +3,7 @@ | |||||||
| namespace ManiaControl\Callbacks; | namespace ManiaControl\Callbacks; | ||||||
|  |  | ||||||
| use ManiaControl\Callbacks\Models\RecordCallback; | use ManiaControl\Callbacks\Models\RecordCallback; | ||||||
| use ManiaControl\Callbacks\Structures\Trackmania\DefaultEventStructure; | use ManiaControl\Callbacks\Structures\TrackMania\OnDefaultEventStructure; | ||||||
| use ManiaControl\ManiaControl; | use ManiaControl\ManiaControl; | ||||||
| use ManiaControl\Utils\Formatter; | use ManiaControl\Utils\Formatter; | ||||||
|  |  | ||||||
| @@ -48,12 +48,12 @@ class TrackManiaCallbacks implements CallbackListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function handleScriptCallbacks($name, $data) { | 	public function handleScriptCallbacks($name, $data) { | ||||||
| 		if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { | 		if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { | ||||||
| 			return; | 			//return; //Leave that disabled while testing/implementing Callbacks | ||||||
| 		} | 		} | ||||||
| 		switch ($name) { | 		switch ($name) { | ||||||
| 			//MP4 New Callbacks | 			//MP4 New Callbacks | ||||||
| 			case Callbacks::TM_EVENTDEFAULT: | 			case Callbacks::TM_ONEVENTDEFAULT: | ||||||
| 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_EVENTDEFAULT, new DefaultEventStructure($this->maniaControl, $data)); | 				$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); | ||||||
| 				break; | 				break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user