added endround command + version increase

This commit is contained in:
kremsy 2017-05-15 21:08:52 +02:00
parent b7de245ccd
commit c6f8c3b42e
3 changed files with 58 additions and 4 deletions

View File

@ -52,7 +52,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
/*
* Constants
*/
const VERSION = '0.215';
const VERSION = '0.216';
const API_VERSION = '2013-04-16';
const MIN_DEDIVERSION = '2017-05-03_21_00';
const SCRIPT_TIMEOUT = 40;

View File

@ -2,6 +2,7 @@
namespace ManiaControl\Players;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\General\Dumpable;
use ManiaControl\General\DumpTrait;
use ManiaControl\General\UsageInformationAble;
@ -92,6 +93,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get the Login of the Player
*
* @api
* @param mixed $player
* @return string
*/
@ -105,6 +107,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get the Escaped Nickname
*
* @api
* @return string
*/
public function getEscapedNickname() {
@ -186,6 +189,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Check if player is not a real player
*
* @api
* @return bool
*/
public function isFakePlayer() {
@ -195,6 +199,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get province
*
* @api
* @return string
*/
public function getProvince() {
@ -204,6 +209,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get the specified Part of the Path
*
* @api
* @param int $partNumber
* @return string
*/
@ -220,6 +226,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get Country
*
* @api
* @return string
*/
public function getCountry() {
@ -229,6 +236,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get Continent
*
* @api
* @return string
*/
public function getContinent() {
@ -270,6 +278,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Get the Cache with the given Name
*
* @api
* @param $object
* @param string $cacheName
* @return mixed
@ -285,6 +294,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Set the Cache Data for the given Name
*
* @api
* @param mixed $object
* @param string $cacheName
* @param mixed $data
@ -297,6 +307,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Destroy a Cache
*
* @api
* @param mixed $object
* @param string $cacheName
*/
@ -315,6 +326,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Gets the Player Data
*
* @api
* @param mixed $object
* @param string $dataName
* @param int $serverIndex
@ -327,6 +339,7 @@ class Player implements Dumpable, UsageInformationAble {
/**
* Sets the Player Data and stores it in the Database
*
* @api
* @param mixed $object
* @param string $dataName
* @param mixed $value
@ -340,6 +353,7 @@ class Player implements Dumpable, UsageInformationAble {
/*
* Check if a Player is muted
*
* @api
* @return bool
*/
public function isMuted() {
@ -352,8 +366,29 @@ class Player implements Dumpable, UsageInformationAble {
return false;
}
/**
* Gets the Auth Level Name of a Player
*
* @api
* @return string
*/
public function getAuthLevelName(){
return AuthenticationManager::getAuthLevelName($this->authLevel);
}
/**
* Gets the Auth Level Abbreviation of a Player
*
* @api
* @return string
*/
public function getAuthLevelAbbreviation(){
return AuthenticationManager::getAuthLevelAbbreviation($this->authLevel);
}
/**
* Var_Dump the Players Cache
* @api
*/
public function dumpCache() {
var_dump($this->cache);

View File

@ -41,6 +41,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
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';
/*
* Private properties
@ -93,9 +94,9 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_HANDLE_WARMUP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
//Triggers a WarmUp Status Callback
try{
try {
$this->maniaControl->getModeScriptEventManager()->getWarmupStatus();
}catch(GameModeException $e){
} catch (GameModeException $e) {
$this->maniaControl->getChat()->sendErrorToAdmins("Not in script mode");
Logger::logError("Not in Script mode");
}
@ -106,9 +107,12 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
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.');
}
}
@ -500,7 +504,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
return;
}
$this->maniaControl->getModeScriptEventManager()->getTrackmaniaPointsRepartition()->setCallable(function (OnPointsRepartitionStructure $structure) use ($player){
$this->maniaControl->getModeScriptEventManager()->getTrackmaniaPointsRepartition()->setCallable(function (OnPointsRepartitionStructure $structure) use ($player) {
$pointRepartitionString = "";
foreach ($structure->getPointsRepartition() as $points) {
$pointRepartitionString .= $points . ',';
@ -509,6 +513,21 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
$this->maniaControl->getChat()->sendInformation('Current Points Distribution: ' . $pointRepartitionString, $player);
});
}
/**
* Handle //endround command
*
* @param array $chatCallback
* @param \ManiaControl\Players\Player $player
*/
public function commandTrackManiaEndRound(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()->forceTrackmaniaRoundEnd();
$this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the Round!');
}
}