Resolved #152 updated callbacks / modescript updates, dedimania seems to be fine
This commit is contained in:
parent
ba67ea6911
commit
68a0c493ae
@ -84,6 +84,9 @@ 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";
|
||||||
|
|
||||||
|
const SM_PLAYERSAFK = "Shootmania.AFK.IsAfk";
|
||||||
|
const SM_AFKPROPERTIES = "Shootmania.AFK.GetProperties";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the PlayerManager Callback in favour of this
|
* Use the PlayerManager Callback in favour of this
|
||||||
*
|
*
|
||||||
|
@ -6,7 +6,10 @@ use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
|
|||||||
use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure;
|
use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnActionCustomEventStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnActionCustomEventStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnActionEvent;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnActionEvent;
|
||||||
|
use ManiaControl\Callbacks\Structures\ShootMania\OnAFKProperties;
|
||||||
|
use ManiaControl\Callbacks\Structures\ShootMania\OnAFKPropertiesStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure;
|
||||||
|
use ManiaControl\Callbacks\Structures\ShootMania\OnBasePlayerObjectTimeStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure;
|
||||||
@ -17,9 +20,9 @@ use ManiaControl\Callbacks\Structures\ShootMania\OnJoustReloadStructure;
|
|||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnJoustRoundResultsStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnJoustRoundResultsStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnJoustSelectedPlayersStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnJoustSelectedPlayersStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnNearMissStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnNearMissStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnBasePlayerObjectTimeStructure;
|
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestActionChange;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestActionChange;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure;
|
||||||
|
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayersAFKStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerTriggersSectorStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerTriggersSectorStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnRoyalPlayerSpawnStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnRoyalPlayerSpawnStructure;
|
||||||
use ManiaControl\Callbacks\Structures\ShootMania\OnRoyalPointsStructure;
|
use ManiaControl\Callbacks\Structures\ShootMania\OnRoyalPointsStructure;
|
||||||
@ -156,6 +159,12 @@ class ShootManiaCallbacks implements CallbackListener {
|
|||||||
case Callbacks::SM_ROYAL_ROUNDWINNER:
|
case Callbacks::SM_ROYAL_ROUNDWINNER:
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRoyalRoundWinnerStructure($this->maniaControl, $data));
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRoyalRoundWinnerStructure($this->maniaControl, $data));
|
||||||
break;
|
break;
|
||||||
|
case Callbacks::SM_AFKPROPERTIES:
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnAFKPropertiesStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
|
case Callbacks::SM_PLAYERSAFK:
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayersAFKStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
|
|||||||
class ModeScriptEventManager implements UsageInformationAble {
|
class ModeScriptEventManager implements UsageInformationAble {
|
||||||
use UsageInformationTrait;
|
use UsageInformationTrait;
|
||||||
|
|
||||||
const API_VERSION = "2.1.0";
|
const API_VERSION = "2.2.0";
|
||||||
|
|
||||||
/** @var ManiaControl $maniaControl */
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl;
|
private $maniaControl;
|
||||||
@ -416,6 +416,31 @@ class ModeScriptEventManager implements UsageInformationAble {
|
|||||||
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_SCORES, $responseId);
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_SCORES, $responseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request the current properties of the AFK libraries.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
||||||
|
*/
|
||||||
|
public function getShootmaniaAFKProperties() {
|
||||||
|
$responseId = $this->generateResponseId();
|
||||||
|
$this->triggerModeScriptEvent(' Shootmania.AFK.GetProperties', array($responseId));
|
||||||
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_AFKPROPERTIES, $responseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the properties of the AFK library.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
* @param int $idleTimeLimit
|
||||||
|
* @param int $spawnTimeLimit
|
||||||
|
* @param int $checkInterval
|
||||||
|
* @param int $forceSpec
|
||||||
|
*/
|
||||||
|
public function setShootmaniaAFKProperties($idleTimeLimit, $spawnTimeLimit, $checkInterval, $forceSpec) {
|
||||||
|
$this->triggerModeScriptEvent('Shootmania.AFK.SetProperties', array(strval($idleTimeLimit), strval($spawnTimeLimit), strval($checkInterval), strval($forceSpec)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
|
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user