deploy first version of Trackmania Rounds Plugin
This commit is contained in:
@ -429,16 +429,17 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
* @param int $authLevelNeeded
|
||||
*/
|
||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, $this->getPermissionLevelNameArray($authLevelNeeded));
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, self::getPermissionLevelNameArray($authLevelNeeded));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PermissionLevelNameArray
|
||||
*
|
||||
* @api
|
||||
* @param $authLevelNeeded
|
||||
* @return array[]
|
||||
*/
|
||||
private function getPermissionLevelNameArray($authLevelNeeded) {
|
||||
public static function getPermissionLevelNameArray($authLevelNeeded) {
|
||||
switch ($authLevelNeeded) {
|
||||
case self::AUTH_LEVEL_MODERATOR:
|
||||
return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN);
|
||||
|
@ -474,6 +474,31 @@ class ModeScriptEventManager implements UsageInformationAble {
|
||||
$this->triggerModeScriptEvent('Trackmania.SetPointsRepartition', $pointArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Trackmania Player Points
|
||||
*
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
* @param string|int $roundPoints //< The round points, use an empty string to not update.
|
||||
* @param string|int $mapPoints //< The map points, use an empty string to not update.
|
||||
* @param string|int $matchPoints //< The match points, use an empty string to not update.
|
||||
*/
|
||||
public function setTrackmaniaPlayerPoints(Player $player, $roundPoints = "", $mapPoints = "", $matchPoints = "") {
|
||||
$login = Player::parseLogin($player);
|
||||
$this->triggerModeScriptEvent('Trackmania.SetPlayerPoints', array($login, strval($roundPoints), strval($mapPoints), strval($matchPoints)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Trackmania Team Points
|
||||
*
|
||||
* @param int $teamId //< Id of the team t. Can be 1 or 2.
|
||||
* @param string|int $roundPoints
|
||||
* @param string|int $mapPoints
|
||||
* @param string|int $matchPoints
|
||||
*/
|
||||
public function setTrackmaniaTeamPoints($teamId, $roundPoints = "", $mapPoints = "", $matchPoints = "") {
|
||||
$this->triggerModeScriptEvent('Trackmania.SetTeamPoints', array(strval($teamId), strval($roundPoints), strval($mapPoints), strval($matchPoints)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
|
||||
*
|
||||
|
@ -40,7 +40,6 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
|
||||
const SETTING_PERMISSION_SHOW_SYSTEMINFO = 'Show SystemInfo';
|
||||
const SETTING_PERMISSION_SHUTDOWN_SERVER = 'Shutdown Server';
|
||||
const SETTING_PERMISSION_CHANGE_SERVERSETTINGS = 'Change ServerSettings';
|
||||
const SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION = 'Handle Points Distribution Settings';
|
||||
const SETTING_PERMISSION_END_ROUND = 'Force end of current Trackmania Round';
|
||||
|
||||
/*
|
||||
@ -106,12 +105,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
|
||||
$this->updateWarmUpMenuItems();
|
||||
|
||||
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm') {
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_END_ROUND, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('setpointsdistribution', $this, 'commandSetPointsRepartition', true, 'Sets the Rounds Point Repartition.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('getpointsdistribution', $this, 'commandGetPointsRepartition', true, 'Gets the Rounds Point Repartition.');
|
||||
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('endround', 'end'), $this, 'commandTrackManiaEndRound', true, 'Ends the Current Round.');
|
||||
}
|
||||
}
|
||||
@ -466,55 +460,6 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
|
||||
$this->maniaControl->getChat()->sendSuccess("Changed max spectators to: {$amount}", $player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle //setpointsrepartition command
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function commandSetPointsRepartition(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for delayed shutdown
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
if (count($params) >= 1) {
|
||||
$pointString = $params[1];
|
||||
$pointArray = explode(',', $pointString);
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaPointsRepartition($pointArray);
|
||||
$this->maniaControl->getChat()->sendInformation('Points Distribution Changed!', $player);
|
||||
$this->commandGetPointsRepartition($chatCallback, $player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('You must provide a point Distribution in the following form: 10,8,6,4,3 !', $player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle //getpointsrepartition command
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function commandGetPointsRepartition(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getModeScriptEventManager()->getTrackmaniaPointsRepartition()->setCallable(function (OnPointsRepartitionStructure $structure) use ($player) {
|
||||
$pointRepartitionString = "";
|
||||
foreach ($structure->getPointsRepartition() as $points) {
|
||||
$pointRepartitionString .= $points . ',';
|
||||
}
|
||||
$pointRepartitionString = substr($pointRepartitionString, 0, -1);
|
||||
|
||||
$this->maniaControl->getChat()->sendInformation('Current Points Distribution: ' . $pointRepartitionString, $player);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle //endround command
|
||||
*
|
||||
|
Reference in New Issue
Block a user