implemented new setting method

This commit is contained in:
Steffen Schröder
2014-05-13 16:03:26 +02:00
parent 1fa1d7ee7d
commit ef9c141786
33 changed files with 606 additions and 551 deletions

View File

@ -113,9 +113,9 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
* @return ManiaLink
*/
private function buildMenuIconsManialink(Player $player) {
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
$posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_POSX);
$posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_POSY);
$itemSize = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();

View File

@ -7,6 +7,7 @@ use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Settings\Setting;
/**
* Class managing Authentication Levels
@ -283,18 +284,21 @@ class AuthenticationManager implements CallbackListener {
* @return bool
*/
public function checkPermission(Player $player, $rightName) {
$right = $this->maniaControl->settingManager->getSetting($this, $rightName);
$right = $this->maniaControl->settingManager->getSettingValue($this, $rightName);
return $this->checkRight($player, $right);
}
/**
* Check if the Player has enough Rights
*
* @param Player $player
* @param int $neededAuthLevel
* @param Player $player
* @param int|Setting $neededAuthLevel
* @return bool
*/
public static function checkRight(Player $player, $neededAuthLevel) {
if ($neededAuthLevel instanceof Setting) {
$neededAuthLevel = $neededAuthLevel->value;
}
return ($player->authLevel >= $neededAuthLevel);
}

View File

@ -53,7 +53,7 @@ class Chat {
* @return bool
*/
public function sendInformation($message, $login = null, $prefix = true) {
$format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_INFORMATION);
$format = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
return $this->sendChat($format . $message, $login, $prefix);
}
@ -82,7 +82,7 @@ class Chat {
* @param bool $prefix
*/
public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
$format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_ERROR);
$format = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FORMAT_ERROR);
$this->sendMessageToAdmins($format . $message, $prefix);
}
@ -102,14 +102,14 @@ class Chat {
if (!$login) {
$prefix = $this->getPrefix($prefix);
$chatMessage = '$<$z$ff0' . str_replace(' ', '', $prefix) . $prefix . $message . '$>';
$this->maniaControl->client->chatSendServerMessage($chatMessage);
$this->maniaControl->client->chatSend($chatMessage, null, true);
} else {
$chatMessage = '$<$z$ff0' . $this->getPrefix($prefix) . $message . '$>';
if (is_object($login) && property_exists($login, 'login')) {
$login = $login->login;
}
try {
$this->maniaControl->client->chatSendServerMessage($chatMessage, $login);
$this->maniaControl->client->chatSend($chatMessage, $login, true);
} catch (LoginUnknownException $e) {
}
}
@ -127,7 +127,7 @@ class Chat {
return $prefix;
}
if ($prefix === true) {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_PREFIX);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_PREFIX);
}
return '';
}
@ -141,7 +141,7 @@ class Chat {
* @return bool
*/
public function sendSuccess($message, $login = null, $prefix = true) {
$format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_SUCCESS);
$format = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
return $this->sendChat($format . $message, $login, $prefix);
}
@ -167,7 +167,7 @@ class Chat {
* @return bool
*/
public function sendError($message, $login = null, $prefix = true) {
$format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_ERROR);
$format = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FORMAT_ERROR);
return $this->sendChat($format . $message, $login, $prefix);
}
@ -180,7 +180,7 @@ class Chat {
* @return bool
*/
public function sendUsageInfo($message, $login = null, $prefix = false) {
$format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_USAGEINFO);
$format = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO);
return $this->sendChat($format . $message, $login, $prefix);
}
}

View File

@ -152,12 +152,12 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
* @return \FML\ManiaLink
*/
private function buildManialink($menuIdShown = 0, Player $player = null) {
$menuPosX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
$menuPosY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
$menuWidth = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_WIDTH);
$menuHeight = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_HEIGHT);
$quadStyle = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_STYLE);
$quadSubstyle = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_SUBSTYLE);
$menuPosX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_POSX);
$menuPosY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_POSY);
$menuWidth = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_WIDTH);
$menuHeight = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_HEIGHT);
$quadStyle = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_STYLE);
$quadSubstyle = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MENU_SUBSTYLE);
$menuListWidth = $menuWidth * 0.3;
$menuItemHeight = 10.;

View File

@ -149,7 +149,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
* @param Map $map
*/
public function onBeginMap(Map $map) {
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN)) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN)) {
$this->loadSettingsFromDatabase();
}
}

View File

@ -71,7 +71,7 @@ class ErrorHandler {
}
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) {
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['ManiaControlVersion'] = ManiaControl::VERSION . ' #' . $this->maniaControl->updateManager->getNightlyBuildDate();
} else {
$error['ManiaControlVersion'] = ManiaControl::VERSION;
@ -107,7 +107,7 @@ class ErrorHandler {
if (!$this->maniaControl || !$this->maniaControl->settingManager) {
return false;
}
$setting = $this->maniaControl->settingManager->getSetting($this, self::SETTING_RESTART_ON_EXCEPTION, true);
$setting = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_RESTART_ON_EXCEPTION, true);
return $setting;
}
@ -158,7 +158,7 @@ class ErrorHandler {
}
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) {
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['ManiaControlVersion'] = ManiaControl::VERSION . ' ' . $this->maniaControl->updateManager->getNightlyBuildDate();
} else {
$error['ManiaControlVersion'] = ManiaControl::VERSION;

View File

@ -67,7 +67,7 @@ class StyleManager {
* @return string
*/
public function getDefaultIconOffsetSM() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_ICON_DEFAULT_OFFSET_SM);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ICON_DEFAULT_OFFSET_SM);
}
/**
@ -76,7 +76,7 @@ class StyleManager {
* @return string
*/
public function getDefaultLabelStyle() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_LABEL_DEFAULT_STYLE);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LABEL_DEFAULT_STYLE);
}
/**
@ -85,7 +85,7 @@ class StyleManager {
* @return string
*/
public function getDefaultQuadStyle() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_QUAD_DEFAULT_STYLE);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_QUAD_DEFAULT_STYLE);
}
/**
@ -94,7 +94,7 @@ class StyleManager {
* @return string
*/
public function getDefaultQuadSubstyle() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE);
}
/**
@ -123,7 +123,7 @@ class StyleManager {
* @return string
*/
public function getListWidgetsWidth() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_LIST_WIDGETS_WIDTH);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LIST_WIDGETS_WIDTH);
}
/**
@ -132,7 +132,7 @@ class StyleManager {
* @return string
*/
public function getListWidgetsHeight() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_LIST_WIDGETS_HEIGHT);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LIST_WIDGETS_HEIGHT);
}
/**
@ -216,7 +216,7 @@ class StyleManager {
* @return string
*/
public function getDefaultMainWindowStyle() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE);
}
/**
@ -225,6 +225,6 @@ class StyleManager {
* @return string
*/
public function getDefaultMainWindowSubStyle() {
return $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE);
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE);
}
}

View File

@ -399,7 +399,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$mapList = array();
foreach ($maps as $map) {
if ($map instanceof Map) {
if ($this->maniaControl->settingManager->getSetting($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) {
if ($this->maniaControl->settingManager->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) {
$karma = $karmaPlugin->getMapKarma($map);
$map->karma = round($karma * 100.);
} else {

View File

@ -422,7 +422,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$karma = $karmaPlugin->getMapKarma($map);
$votes = $karmaPlugin->getMapVotes($map);
if (is_numeric($karma)) {
if ($this->maniaControl->settingManager->getSetting($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) {
if ($this->maniaControl->settingManager->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) {
$karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';
} else {
$min = 0;

View File

@ -272,6 +272,7 @@ class MapManager implements CallbackListener {
* @param MXMapInfo $mapInfo
* @param string $login
* @param bool $update
* @throws InvalidArgumentException
*/
private function processMapFile($file, MXMapInfo $mapInfo, $login, $update) {
// Check if map is already on the server
@ -285,7 +286,7 @@ class MapManager implements CallbackListener {
$fileName = $mapInfo->id . '_' . $mapInfo->name . '.Map.Gbx';
$fileName = FileUtil::getClearedFileName($fileName);
$downloadFolderName = $this->maniaControl->settingManager->getSetting($this, 'MapDownloadDirectory', 'MX');
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
$mapDir = $this->maniaControl->client->getMapsDirectory();
$downloadDirectory = $mapDir . DIRECTORY_SEPARATOR . $downloadFolderName . DIRECTORY_SEPARATOR;
@ -403,9 +404,10 @@ class MapManager implements CallbackListener {
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPS_UPDATED);
// Write MapList
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_AUTOSAVE_MAPLIST)) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_AUTOSAVE_MAPLIST)) {
$matchSettingsFileName = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIST_FILE);
try {
$this->maniaControl->client->saveMatchSettings($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAPLIST_FILE));
$this->maniaControl->client->saveMatchSettings($matchSettingsFileName);
} catch (CouldNotWritePlaylistFileException $e) {
$this->maniaControl->log("Unable to write the playlist file, please checkout your MX-Folders File permissions!");
}
@ -649,7 +651,7 @@ class MapManager implements CallbackListener {
* @param bool $restart
*/
private function beginMap($uid, $restart = false) {
//If a restart occured, first call the endMap to set variables back
//If a restart occurred, first call the endMap to set variables back
if ($restart) {
$this->endMap();
}

View File

@ -235,8 +235,8 @@ class MapQueue implements CallbackListener, CommandListener {
}
}
$maxPlayer = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAPLIMIT_PLAYER);
$maxAdmin = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAPLIMIT_ADMIN);
$maxPlayer = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
$maxAdmin = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
if ($admin && $maxAdmin != -1) {
if ($mapsForPlayer == $maxAdmin) {
@ -309,7 +309,7 @@ class MapQueue implements CallbackListener, CommandListener {
}
$this->nextMap = null;
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) {
//Skip Map if requester has left
foreach ($this->queuedMaps as $queuedMap) {
@ -325,7 +325,7 @@ class MapQueue implements CallbackListener, CommandListener {
break;
}
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN) == false) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN) == false) {
//Check if the queuer is a admin
if ($player->authLevel > 0) {
break;
@ -368,7 +368,7 @@ class MapQueue implements CallbackListener, CommandListener {
return;
}
if (count($this->buffer) >= $this->maniaControl->settingManager->getSetting($this, self::SETTING_BUFFERSIZE)) {
if (count($this->buffer) >= $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_BUFFERSIZE)) {
array_shift($this->buffer);
}

View File

@ -246,7 +246,7 @@ class PlayerManager implements CallbackListener, TimerListener {
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
$this->maniaControl->log(Formatter::stripCodes($logMessage));
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
$this->maniaControl->chat->sendChat('$0f0$<$fff' . $player->nickname . '$> has left the game');
}
@ -332,7 +332,7 @@ class PlayerManager implements CallbackListener, TimerListener {
//Check if Player finished joining the game
if ($player->hasJoinedGame && !$prevJoinState) {
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
$chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined!';
$this->maniaControl->chat->sendChat($chatMessage);

View File

@ -56,7 +56,7 @@ class ScriptManager {
} catch (Exception $e) {
// TODO temp added 19.04.2014
$this->maniaControl->errorHandler->handleException($e, false);
trigger_error("Couldn't set Mode Script Settings to {$actionName}able Script Sallbacks. " . $e->getMessage());
trigger_error("Couldn't set Mode Script Settings to {$actionName}able Script Callbacks. " . $e->getMessage());
return false;
}
$this->maniaControl->log("Script Callbacks successfully {$actionName}abled!");

View File

@ -58,11 +58,11 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
// Register for commands
$this->maniaControl->commandManager->registerCommandListener('setpwd', $this, 'command_SetPwd', true, 'Sets play password.');
$this->maniaControl->commandManager->registerCommandListener('setservername', $this, 'command_SetServerName', true, 'Sets the servername.');
$this->maniaControl->commandManager->registerCommandListener('setpwd', $this, 'command_SetPwd', true, 'Sets play password.');
$this->maniaControl->commandManager->registerCommandListener('setspecpwd', $this, 'command_SetSpecPwd', true, 'Sets spectator password.');
$this->maniaControl->commandManager->registerCommandListener('setmaxplayers', $this, 'command_SetMaxPlayers', true, 'Sets the maximum number of players.');
$this->maniaControl->commandManager->registerCommandListener('setmaxspectators', $this, 'command_SetMaxSpectators', true, 'Sets the maximum number of spectators.');
$this->maniaControl->commandManager->registerCommandListener('setspecpwd', $this, 'command_SetSpecPwd', true, 'Sets spectator password.');
$this->maniaControl->commandManager->registerCommandListener('shutdownserver', $this, 'command_ShutdownServer', true, 'Shuts down the ManiaPlanet server.');
$this->maniaControl->commandManager->registerCommandListener('systeminfo', $this, 'command_SystemInfo', true, 'Shows system information.');

View File

@ -3,10 +3,10 @@
namespace ManiaControl\Server;
use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Utils\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Plugins\Plugin;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
/**
* Class reporting ManiaControl Usage for the Server
@ -46,7 +46,7 @@ class UsageReporter implements TimerListener {
* @param float $time
*/
public function reportUsage($time) {
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_REPORT_USAGE)) {
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_REPORT_USAGE)) {
return;
}
@ -69,12 +69,8 @@ class UsageReporter implements TimerListener {
try {
$scriptName = $this->maniaControl->client->getScriptName();
$properties['ScriptName'] = $scriptName['CurrentValue'];
} catch (Exception $e) {
if ($e->getMessage() == 'Not in script mode.') {
$properties['ScriptName'] = '';
} else {
throw $e;
}
} catch (NotInScriptModeException $e) {
$properties['ScriptName'] = '';
}
$activePlugins = array();

View File

@ -260,6 +260,22 @@ class SettingManager implements CallbackListener {
return true;
}
/**
* Get the Setting Value directly
*
* @param mixed $object
* @param string $settingName
* @param mixed $default
* @return mixed
*/
public function getSettingValue($object, $settingName, $default = null) {
$setting = $this->getSetting($object, $settingName, $default);
if ($setting) {
return $setting->value;
}
return null;
}
/**
* Reset a Setting to its Default Value
*

View File

@ -109,7 +109,7 @@ class StatisticCollector implements CallbackListener {
*/
public function onEndMap(array $callback) {
//Check for Minimum PlayerCount
if (count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
if (count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
return;
}
@ -128,7 +128,7 @@ class StatisticCollector implements CallbackListener {
*/
public function onPlayerDisconnect(Player $player) {
// Check if Stat Collecting is enabled
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
return;
}
@ -146,14 +146,15 @@ class StatisticCollector implements CallbackListener {
*
* @param array $callback
*/
public function handleCallbacks(array $callback) { //TODO survivals
public function handleCallbacks(array $callback) {
//TODO survivals
//Check if Stat Collecting is enabled
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
return;
}
//Check for Minimum PlayerCount
if (count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
if (count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
return;
}
@ -277,7 +278,7 @@ class StatisticCollector implements CallbackListener {
}
//Write Shoot Data into database
if (array_sum($this->onShootArray[$login]) > $this->maniaControl->settingManager->getSetting($this, self::SETTING_ON_SHOOT_PRESTORE)) {
if (array_sum($this->onShootArray[$login]) > $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ON_SHOOT_PRESTORE)) {
$player = $this->maniaControl->playerManager->getPlayer($login);
$rocketShots = $this->onShootArray[$login][self::WEAPON_ROCKET];

View File

@ -178,7 +178,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
}
$this->maniaControl->log($message);
$performBackup = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_PERFORM_BACKUPS);
$performBackup = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->updateManager, UpdateManager::SETTING_PERFORM_BACKUPS);
if ($performBackup && !BackupUtil::performPluginsBackup()) {
$message = 'Creating Backup before Plugins Update failed!';
if ($player) {

View File

@ -60,13 +60,12 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
// 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, 1);
$updateIntervalSetting = $this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 1);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, self::CHANNEL_BETA);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_PERFORM_BACKUPS, true);
// Register for callbacks
$updateInterval = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_INTERVAL);
$this->maniaControl->timerManager->registerTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60 * $updateInterval);
$this->maniaControl->timerManager->registerTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60 * $updateIntervalSetting->value);
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
@ -88,7 +87,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* @param float $time
*/
public function hourlyUpdateCheck($time) {
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
$updateCheckEnabled = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ENABLEUPDATECHECK);
if (!$updateCheckEnabled) {
$this->setCoreUpdateData();
return;
@ -138,7 +137,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* @return string
*/
public function getCurrentUpdateChannelSetting() {
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
$updateChannel = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_UPDATECHECK_CHANNEL);
$updateChannel = strtolower($updateChannel);
if (!in_array($updateChannel, array(self::CHANNEL_RELEASE, self::CHANNEL_BETA, self::CHANNEL_NIGHTLY))) {
$updateChannel = self::CHANNEL_RELEASE;
@ -249,7 +248,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* Check if an automatic Update should be performed
*/
public function checkAutoUpdate() {
$autoUpdate = $this->maniaControl->settingManager->getSetting($this, self::SETTING_AUTO_UPDATE);
$autoUpdate = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_AUTO_UPDATE);
if (!$autoUpdate) {
// Auto update turned off
return;
@ -294,7 +293,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
return false;
}
$performBackup = $this->maniaControl->settingManager->getSetting($this, self::SETTING_PERFORM_BACKUPS);
$performBackup = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_PERFORM_BACKUPS);
if ($performBackup && !BackupUtil::performFullBackup()) {
$message = 'Creating Backup before Update failed!';
if ($player) {