moved the endrounds to the new plugin

This commit is contained in:
kremsy 2017-05-17 12:48:46 +02:00
parent 9ff8989a00
commit fb5e7b3d96
3 changed files with 25 additions and 25 deletions

View File

@ -23,7 +23,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
class ModeScriptEventManager implements UsageInformationAble {
use UsageInformationTrait;
const API_VERSION = "2.0.0";
const API_VERSION = "2.1.0";
/** @var ManiaControl $maniaControl */
private $maniaControl;

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_END_ROUND = 'Force end of current Trackmania Round';
/*
* Private properties
@ -103,11 +102,6 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
$this->updateCancelVoteMenuItem();
$this->updateWarmUpMenuItems();
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm') {
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_END_ROUND, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getCommandManager()->registerCommandListener(array('endround', 'end'), $this, 'commandTrackManiaEndRound', true, 'Ends the Current Round.');
}
}
/**
@ -459,20 +453,4 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer
$this->maniaControl->getClient()->setMaxSpectators($amount);
$this->maniaControl->getChat()->sendSuccess("Changed max spectators to: {$amount}", $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_END_ROUND)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$this->maniaControl->getModeScriptEventManager()->forceTrackmaniaRoundEnd();
$this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the Round!');
}
}

View File

@ -10,7 +10,7 @@ use ManiaControl\Players\Player;
use ManiaControl\Plugins\Plugin;
/**
* ManiaControl ServerRanking Plugin
* ManiaControl Trackmania Rounds Plugin
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
@ -27,7 +27,8 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
const MAX_POINT_DISTRIBUTIONS = 8;
const SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION = 'Handle Points Distribution Settings';
const SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION = 'Permission handle Points Distribution Settings';
const SETTING_PERMISSION_END_ROUND = 'Permission Force end of current Trackmania Round';
const SETTING_POINT_DISTRIBUTION_NAME = 'Server Distribution Name ';
const SETTING_POINT_DISTRIBUTION_VALUE = 'Server Distribution Value ';
@ -52,6 +53,7 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
//Authentication Permission Level
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PERMISSION_TM_HANDLE_POINTS_REPARTITION, AuthenticationManager::getPermissionLevelNameArray(AuthenticationManager::AUTH_LEVEL_ADMIN));
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PERMISSION_END_ROUND, AuthenticationManager::getPermissionLevelNameArray(AuthenticationManager::AUTH_LEVEL_MODERATOR));
//Settings
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_POINT_DISTRIBUTION_NAME . 1, "motogp");
@ -62,11 +64,14 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_POINT_DISTRIBUTION_VALUE . $i, "");
}
// Commands
$this->maniaControl->getCommandManager()->registerCommandListener(array('setrpoints',
'setpointsdistribution'), $this, 'commandSetPointsRepartition', true, 'Sets the Rounds Point Repartition.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('getrpoints',
'getpointsdistribution'), $this, 'commandGetPointsRepartition', true, 'Gets the Rounds Point Repartition.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('endround', 'end'), $this, 'commandTrackManiaEndRound', true, 'Ends the Current Round.');
}
/**
@ -133,6 +138,23 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
});
}
/**
* Handle //endround command
*
* @param array $chatCallback
* @param \ManiaControl\Players\Player $player
*/
public function commandTrackManiaEndRound(array $chatCallback, Player $player) {
$permission = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PERMISSION_END_ROUND);
if (!AuthenticationManager::checkRight($player, $permission)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$this->maniaControl->getModeScriptEventManager()->forceTrackmaniaRoundEnd();
$this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the Round!');
}
/**
* @see \ManiaControl\Plugins\Plugin::getId()
*/