Resolved #152 updated callbacks / modescript updates, dedimania seems to be fine

This commit is contained in:
kremsy
2017-06-21 19:25:58 +02:00
parent ba67ea6911
commit 68a0c493ae
5 changed files with 171 additions and 2 deletions

View File

@ -0,0 +1,74 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the AFK Properties Callback
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnAFKPropertiesStructure extends BaseResponseStructure {
protected $idleTimeLimit;
protected $spawnTimeLimit;
protected $checkInterval;
protected $forceSpec;
/**
* 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->idleTimeLimit = $jsonObj->idletimelimit;
$this->spawnTimelimit = $jsonObj->spawntimelimit;
$this->checkInterval = $jsonObj->checkinterval;
$this->forceSpec = $jsonObj->forcespec;
}
/**
* Time after which a player is considered to be AFK (ms)
*
* @api
* @return int
*/
public function getIdleTimeLimit() {
return (int) $this->idleTimeLimit;
}
/**
* Time after spawn before which a player can't be considered to be
*
* @return int
*/
public function getSpawnTimeLimit() {
return (int) $this->spawnTimeLimit;
}
/**
* Time between each AFK check (ms)
*
* @return int
*/
public function getCheckInterval() {
return (int) $this->checkInterval;
}
/**
* Let the library force the AFK player into spectator mode
*
* @return bool
*/
public function getForceSpec() {
return $this->forceSpec;
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the AFK.IsAFK Structure Callback
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnPlayersAFKStructure extends BaseStructure {
protected $logins;
/**
* 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->logins = $jsonObj->logins;
}
/**
* Returns a Login Array of the defenders
*
* @api
* @return array
*/
public function getAFKPlayerLogins() {
return $this->logins;
}
/**
* Gets an Array of the Players
*
* @api
* @return \ManiaControl\Players\Player[]
*/
public function getAFKPlayers() {
$afkPlayers = array();
foreach ($this->logins as $login) {
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if ($player) {
$afkPlayers[$login] = $player;
}
}
return $afkPlayers;
}
}