From 2e982ce5a9b9748f4ab1b991188980f329eef79f Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 21 Jan 2014 19:12:55 +0100 Subject: [PATCH] small improvements --- application/core/UpdateManager.php | 10 +++++++- application/plugins/CustomVotes.php | 40 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/application/core/UpdateManager.php b/application/core/UpdateManager.php index 5da592b7..796df7e1 100644 --- a/application/core/UpdateManager.php +++ b/application/core/UpdateManager.php @@ -22,6 +22,7 @@ class UpdateManager implements CallbackListener, CommandListener { const SETTING_UPDATECHECK_INTERVAL = 'Core Update Check Interval (Hours)'; const SETTING_UPDATECHECK_CHANNEL = 'Core Update Channel (release, beta, nightly)'; const SETTING_PERFORM_BACKUPS = 'Perform Backup before Updating'; + const SETTING_AUTO_UPDATE = 'Perform update automatically'; const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; const CHANNEL_RELEASE = 'release'; const CHANNEL_BETA = 'beta'; @@ -44,10 +45,12 @@ class UpdateManager implements CallbackListener, CommandListener { // Init settings $this->maniaControl->settingManager->initSetting($this, self::SETTING_ENABLEUPDATECHECK, true); + $this->maniaControl->settingManager->initSetting($this, self::SETTING_AUTO_UPDATE, true); $this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 24.); $this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, self::CHANNEL_NIGHTLY); //TODO just temp until release $this->maniaControl->settingManager->initSetting($this, self::SETTING_PERFORM_BACKUPS, true); + // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handle1Minute'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined'); @@ -109,7 +112,12 @@ class UpdateManager implements CallbackListener, CommandListener { * @param array $callback */ public function handlePlayerDisconnected(array $callback) { - //TODO Setting for autoupdate + $performBackup = $this->maniaControl->settingManager->getSetting($this, self::SETTING_AUTO_UPDATE); + if(!$performBackup) { + return; + } + + if(count($this->maniaControl->playerManager->getPlayers()) > 0) { return; } diff --git a/application/plugins/CustomVotes.php b/application/plugins/CustomVotes.php index a35004e7..6400b95d 100644 --- a/application/plugins/CustomVotes.php +++ b/application/plugins/CustomVotes.php @@ -23,6 +23,7 @@ use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; use ManiaControl\Server\ServerCommands; +use Maniaplanet\DedicatedServer\Structures\VoteRatio; /** @@ -119,12 +120,33 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $this->maniaControl->settingManager->initSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE, false); $this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_TIME, 60); + //Define Votes $this->defineVote("teambalance", "Team Balance"); $this->defineVote("skipmap", "Skip Map"); $this->defineVote("nextmap", "Skip Map"); $this->defineVote("restartmap", "Restart Map"); $this->defineVote("pausegame", "Pause Game"); + /* Disable Standard Votes */ + $array["Command"] = VoteRatio::COMMAND_BAN; + $array["Param"] = ""; + $array["Ratio"] = (float)-1; + $ratioArray[] = $array; + + $array["Command"] = VoteRatio::COMMAND_KICK; + $ratioArray[] = $array; + + $array["Command"] = VoteRatio::COMMAND_RESTART_MAP; + $ratioArray[] = $array; + + $array["Command"] = VoteRatio::COMMAND_TEAM_BALANCE; + $ratioArray[] = $array; + + $array["Command"] = VoteRatio::COMMAND_NEXT_MAP; + $ratioArray[] = $array; + + $this->maniaControl->client->setCallVoteRatiosEx(false, $ratioArray); + $this->constructMenu(); return true; } @@ -133,6 +155,24 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP * Unload the plugin and its resources */ public function unload() { + //Enable Standard Votes + $defaultRatio = $this->maniaControl->client->getCallVoteRatio(); + + $array["Command"] = VoteRatio::COMMAND_BAN; + $array["Param"] = ""; + $array["Ratio"] = (float)$defaultRatio; + $ratioArray[] = $array; + $array["Command"] = VoteRatio::COMMAND_KICK; + $ratioArray[] = $array; + $array["Command"] = VoteRatio::COMMAND_RESTART_MAP; + $ratioArray[] = $array; + $array["Command"] = VoteRatio::COMMAND_TEAM_BALANCE; + $ratioArray[] = $array; + $array["Command"] = VoteRatio::COMMAND_NEXT_MAP; + $ratioArray[] = $array; + + $this->maniaControl->client->setCallVoteRatiosEx(false, $ratioArray); + $this->destroyVote(); $emptyManialink = new ManiaLink(self::MLID_ICON); $manialinkText = $emptyManialink->render()->saveXML();