Merge pull request #226 from jonthekiller/jonthekiller-patch-1

Add //endwu to be able to stop a WarmUp
This commit is contained in:
Jocy Wolff 2019-12-28 14:10:21 +01:00 committed by GitHub
commit ffe1ab05dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 1 deletions

View File

@ -21,7 +21,7 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
* Constants
*/
const PLUGIN_ID = 6;
const PLUGIN_VERSION = 0.11;
const PLUGIN_VERSION = 0.12;
const PLUGIN_NAME = 'Trackmania Rounds Plugin';
const PLUGIN_AUTHOR = 'MCTeam';
@ -71,6 +71,7 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
$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.');
$this->maniaControl->getCommandManager()->registerCommandListener('endwu', $this, 'commandTrackManiaEndWarmUp', true, 'Ends the Current WarmUp.');
}
@ -149,6 +150,25 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
$this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the Round!');
}
/**
* Handle //endwu command
*
* @param array $chatCallback
* @param \ManiaControl\Players\Player $player
*/
public function commandTrackManiaEndWarmUp(array $chatCallback, Player $player) {
$permission = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PERMISSION_END_ROUND);
if (!AuthenticationManager::checkRight($player, AuthenticationManager::getAuthLevel($permission))) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
try {
$this->maniaControl->getModeScriptEventManager()->triggerModeScriptEvent("Trackmania.WarmUp.ForceStop");
} catch (\Throwable $e) {
}
$this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the WarmUp!');
}
/**
* @see \ManiaControl\Plugins\Plugin::getId()
*/