deploy first version of Trackmania Rounds Plugin

This commit is contained in:
kremsy
2017-05-17 12:18:15 +02:00
parent 1eea876a3b
commit e0290b6947
4 changed files with 206 additions and 57 deletions

View File

@ -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
*