small improvements

This commit is contained in:
kremsy 2014-01-21 19:12:55 +01:00 committed by Steffen Schröder
parent 64946bf3a1
commit 2e982ce5a9
2 changed files with 49 additions and 1 deletions

View File

@ -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;
}

View File

@ -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();