added jsonserializable interface / trait
This commit is contained in:
parent
738c7a134c
commit
527c37d006
@ -11,7 +11,7 @@
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Run configuration
|
||||
define('DEV_MODE', false); // Development mode to not send error reports etc.
|
||||
define('DEV_MODE', true); // Development mode to not send error reports etc.
|
||||
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
|
||||
define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder
|
||||
|
||||
|
@ -10,6 +10,8 @@ use ManiaControl\Players\Player;
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*
|
||||
* @deprecated see OnArmorEmptyStructure
|
||||
*/
|
||||
class ArmorEmptyStructure {
|
||||
/*
|
||||
|
@ -11,6 +11,8 @@ use ManiaControl\Players\Player;
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*
|
||||
* @deprecated see Capture Structure
|
||||
*/
|
||||
class CaptureStructure {
|
||||
/*
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace ManiaControl\Callbacks\Structures\Common;
|
||||
|
||||
|
||||
use ManiaControl\General\JsonSerializable;
|
||||
use ManiaControl\General\JsonSerializeTrait;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
@ -14,8 +16,8 @@ use ManiaControl\ManiaControl;
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
abstract class BaseStructure implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
abstract class BaseStructure implements UsageInformationAble, JsonSerializable {
|
||||
use UsageInformationTrait, JsonSerializeTrait;
|
||||
|
||||
/** @var ManiaControl $maniaControl */
|
||||
protected $maniaControl;
|
||||
|
@ -5,6 +5,8 @@ namespace ManiaControl\Callbacks\Structures\Common;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
|
||||
use ManiaControl\General\JsonSerializable;
|
||||
use ManiaControl\General\JsonSerializeTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
@ -43,7 +45,7 @@ class CommonScoresStructure extends BaseStructure {
|
||||
$teamScore = new \ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore();
|
||||
}
|
||||
|
||||
$teamScore->setId($team->id);
|
||||
$teamScore->setTeamId($team->id);
|
||||
$teamScore->setName($team->name);
|
||||
$teamScore->setRoundPoints($team->roundpoints);
|
||||
$teamScore->setMatchPoints($team->matchpoints);
|
||||
|
@ -3,12 +3,21 @@
|
||||
namespace ManiaControl\Callbacks\Structures\Common\Models;
|
||||
|
||||
|
||||
use ManiaControl\General\JsonSerializable;
|
||||
use ManiaControl\General\JsonSerializeTrait;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
class CommonPlayerScore implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
/**
|
||||
* Common PlayerStructure Model
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonPlayerScore implements UsageInformationAble, JsonSerializable {
|
||||
use UsageInformationTrait, JsonSerializeTrait;
|
||||
|
||||
protected $player;
|
||||
protected $rank;
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\Common\Models;
|
||||
|
||||
use ManiaControl\General\JsonSerializable;
|
||||
use ManiaControl\General\JsonSerializeTrait;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
|
||||
@ -12,10 +14,10 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonTeamScore implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
class CommonTeamScore implements UsageInformationAble, JsonSerializable {
|
||||
use UsageInformationTrait, JsonSerializeTrait;
|
||||
|
||||
private $id;
|
||||
private $teamId;
|
||||
private $name;
|
||||
private $roundPoints;
|
||||
private $mapPoints;
|
||||
@ -24,15 +26,15 @@ class CommonTeamScore implements UsageInformationAble {
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
public function getTeamId() {
|
||||
return $this->teamId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
public function setTeamId($id) {
|
||||
$this->teamId = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,8 @@ use ManiaControl\Players\Player;
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*
|
||||
* @deprecated see OnNearMissStructure
|
||||
*/
|
||||
class NearMissStructure {
|
||||
/*
|
||||
|
@ -11,6 +11,8 @@ use ManiaControl\Players\Player;
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*
|
||||
* @deprecated see OnPlayerHitStructure
|
||||
*/
|
||||
class PlayerHitStructure {
|
||||
/*
|
||||
|
12
core/General/JsonSerializable.php
Normal file
12
core/General/JsonSerializable.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
/**
|
||||
* Object implementing this Interface has a toJson() Method
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
interface JsonSerializable {
|
||||
public function toJson();
|
||||
}
|
14
core/General/JsonSerializeTrait.php
Normal file
14
core/General/JsonSerializeTrait.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
/**
|
||||
* Class DumpTrait Trait for Implementing the Methods for the JsonSerializeable Interface
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
trait JsonSerializeTrait {
|
||||
public function toJson(){
|
||||
return json_encode(get_object_vars($this));
|
||||
}
|
||||
}
|
@ -130,6 +130,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
var_dump("tesst");
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Commands
|
||||
|
Loading…
Reference in New Issue
Block a user