Add //endwu to be able to stop a WarmUp

Adding //endwu command to be able to stop the WarmUp in progress.
This commit is contained in:
jonthekiller 2019-07-15 21:25:49 +02:00 committed by GitHub
parent 3a10908d25
commit 9d0677364e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 2 deletions

View File

@ -13,7 +13,7 @@ use ManiaControl\Plugins\Plugin;
* ManiaControl Trackmania Rounds Plugin
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2019 ManiaControl Team
* @copyright 2014-2018 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TrackmaniaRoundsPlugin implements Plugin, CommandListener {
@ -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()
*/