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

@ -123,7 +123,7 @@ spl_autoload_register(function ($className) {
// Plugin file // Plugin file
$filePath = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php'; $filePath = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php';
if (file_exists($filePath)) { if (file_exists($filePath)) {
require_once $filePath; include_once $filePath;
return; return;
} }
}); });

View File

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

View File

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

View File

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

View File

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

View File

@ -149,7 +149,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
* @param Map $map * @param Map $map
*/ */
public function onBeginMap(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(); $this->loadSettingsFromDatabase();
} }
} }

View File

@ -71,7 +71,7 @@ class ErrorHandler {
} }
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) { 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(); $error['ManiaControlVersion'] = ManiaControl::VERSION . ' #' . $this->maniaControl->updateManager->getNightlyBuildDate();
} else { } else {
$error['ManiaControlVersion'] = ManiaControl::VERSION; $error['ManiaControlVersion'] = ManiaControl::VERSION;
@ -107,7 +107,7 @@ class ErrorHandler {
if (!$this->maniaControl || !$this->maniaControl->settingManager) { if (!$this->maniaControl || !$this->maniaControl->settingManager) {
return false; 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; return $setting;
} }
@ -158,7 +158,7 @@ class ErrorHandler {
} }
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) { 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(); $error['ManiaControlVersion'] = ManiaControl::VERSION . ' ' . $this->maniaControl->updateManager->getNightlyBuildDate();
} else { } else {
$error['ManiaControlVersion'] = ManiaControl::VERSION; $error['ManiaControlVersion'] = ManiaControl::VERSION;

View File

@ -67,7 +67,7 @@ class StyleManager {
* @return string * @return string
*/ */
public function getDefaultIconOffsetSM() { 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 * @return string
*/ */
public function getDefaultLabelStyle() { 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 * @return string
*/ */
public function getDefaultQuadStyle() { 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 * @return string
*/ */
public function getDefaultQuadSubstyle() { 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 * @return string
*/ */
public function getListWidgetsWidth() { 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 * @return string
*/ */
public function getListWidgetsHeight() { 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 * @return string
*/ */
public function getDefaultMainWindowStyle() { 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 * @return string
*/ */
public function getDefaultMainWindowSubStyle() { 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(); $mapList = array();
foreach ($maps as $map) { foreach ($maps as $map) {
if ($map instanceof 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); $karma = $karmaPlugin->getMapKarma($map);
$map->karma = round($karma * 100.); $map->karma = round($karma * 100.);
} else { } else {

View File

@ -422,7 +422,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$karma = $karmaPlugin->getMapKarma($map); $karma = $karmaPlugin->getMapKarma($map);
$votes = $karmaPlugin->getMapVotes($map); $votes = $karmaPlugin->getMapVotes($map);
if (is_numeric($karma)) { 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'] . ')'; $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';
} else { } else {
$min = 0; $min = 0;

View File

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

View File

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

View File

@ -246,7 +246,7 @@ class PlayerManager implements CallbackListener, TimerListener {
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}"; $logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
$this->maniaControl->log(Formatter::stripCodes($logMessage)); $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'); $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 //Check if Player finished joining the game
if ($player->hasJoinedGame && !$prevJoinState) { 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'); $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!'; $chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined!';
$this->maniaControl->chat->sendChat($chatMessage); $this->maniaControl->chat->sendChat($chatMessage);

View File

@ -56,7 +56,7 @@ class ScriptManager {
} catch (Exception $e) { } catch (Exception $e) {
// TODO temp added 19.04.2014 // TODO temp added 19.04.2014
$this->maniaControl->errorHandler->handleException($e, false); $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; return false;
} }
$this->maniaControl->log("Script Callbacks successfully {$actionName}abled!"); $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'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
// Register for commands // 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('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('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('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('shutdownserver', $this, 'command_ShutdownServer', true, 'Shuts down the ManiaPlanet server.');
$this->maniaControl->commandManager->registerCommandListener('systeminfo', $this, 'command_SystemInfo', true, 'Shows system information.'); $this->maniaControl->commandManager->registerCommandListener('systeminfo', $this, 'command_SystemInfo', true, 'Shows system information.');

View File

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

View File

@ -260,6 +260,22 @@ class SettingManager implements CallbackListener {
return true; 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 * Reset a Setting to its Default Value
* *

View File

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

View File

@ -178,7 +178,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
} }
$this->maniaControl->log($message); $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()) { if ($performBackup && !BackupUtil::performPluginsBackup()) {
$message = 'Creating Backup before Plugins Update failed!'; $message = 'Creating Backup before Plugins Update failed!';
if ($player) { if ($player) {

View File

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

View File

@ -399,7 +399,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iAway From Keyboard!'; $msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iAway From Keyboard!';
$this->maniaControl->chat->sendChat($msg, null, false); $this->maniaControl->chat->sendChat($msg, null, false);
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_AFK_FORCE_SPEC)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_AFK_FORCE_SPEC)) {
if ($player->isSpectator) { if ($player->isSpectator) {
return; return;
} }

View File

@ -103,7 +103,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
* Build the Log File Name and Folder * Build the Log File Name and Folder
*/ */
private function buildLogFileName() { private function buildLogFileName() {
$folderName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FOLDERNAME); $folderName = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FOLDERNAME);
$folderName = FileUtil::getClearedFileName($folderName); $folderName = FileUtil::getClearedFileName($folderName);
$folderDir = ManiaControlDir . $folderName; $folderDir = ManiaControlDir . $folderName;
if (!is_dir($folderDir)) { if (!is_dir($folderDir)) {
@ -112,9 +112,9 @@ class ChatlogPlugin implements CallbackListener, Plugin {
trigger_error("Couldn't create ChatlogPlugin Log-Folder '{$folderName}'!"); trigger_error("Couldn't create ChatlogPlugin Log-Folder '{$folderName}'!");
} }
} }
$fileName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FILENAME); $fileName = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_FILENAME);
$fileName = FileUtil::getClearedFileName($fileName); $fileName = FileUtil::getClearedFileName($fileName);
$usePId = $this->maniaControl->settingManager->getSetting($this, self::SETTING_USEPID); $usePId = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_USEPID);
if ($usePId) { if ($usePId) {
$dotIndex = strripos($fileName, '.'); $dotIndex = strripos($fileName, '.');
$pIdPart = '_' . getmypid(); $pIdPart = '_' . getmypid();
@ -142,7 +142,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
$data = $chatCallback[1]; $data = $chatCallback[1];
if ($data[0] <= 0) { if ($data[0] <= 0) {
// Server message // Server message
$logServerMessages = $this->maniaControl->settingManager->getSetting($this, self::SETTING_LOGSERVERMESSAGES); $logServerMessages = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LOGSERVERMESSAGES);
if (!$logServerMessages) { if (!$logServerMessages) {
// Skip it // Skip it
return; return;

View File

@ -18,7 +18,6 @@ use FML\Script\Features\KeyAction;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Utils\ColorUtil;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
@ -27,6 +26,7 @@ use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
use ManiaControl\Server\Server; use ManiaControl\Server\Server;
use ManiaControl\Server\ServerCommands; use ManiaControl\Server\ServerCommands;
use ManiaControl\Utils\ColorUtil;
use Maniaplanet\DedicatedServer\Structures\VoteRatio; use Maniaplanet\DedicatedServer\Structures\VoteRatio;
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException; use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
@ -38,6 +38,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
* @copyright 2014 ManiaControl Team * @copyright 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
// TODO: create dedicated files for used classes
class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin { class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin {
/* /*
* Constants * Constants
@ -196,7 +197,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
*/ */
public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) { public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) {
if ($neededRatio == -1) { if ($neededRatio == -1) {
$neededRatio = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_RATIO); $neededRatio = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_RATIO);
} }
$voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio); $voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio);
$voteCommand->startText = $startText; $voteCommand->startText = $startText;
@ -275,10 +276,10 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
* @param bool $login * @param bool $login
*/ */
private function showIcon($login = false) { private function showIcon($login = false) {
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_POSX); $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_ICON_POSX);
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_POSY); $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_ICON_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_ICON_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_ICON_HEIGHT);
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM(); $shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -437,7 +438,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
} }
// Spectators are not allowed to start a vote // Spectators are not allowed to start a vote
if ($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE)) { if ($player->isSpectator && !$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE)) {
$this->maniaControl->chat->sendError('Spectators are not allowed to start a vote.', $player->login); $this->maniaControl->chat->sendError('Spectators are not allowed to start a vote.', $player->login);
return; return;
} }
@ -454,13 +455,13 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
return; return;
} }
$maxTime = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_TIME); $maxTime = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_TIME);
$this->currentVote = $this->voteCommands[$voteIndex]; $this->currentVote = $this->voteCommands[$voteIndex];
$this->currentVote = new CurrentVote($this->voteCommands[$voteIndex], $player, time() + $maxTime); $this->currentVote = new CurrentVote($this->voteCommands[$voteIndex], $player, time() + $maxTime);
$this->currentVote->neededRatio = floatval($this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_RATIO)); $this->currentVote->neededRatio = floatval($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_RATIO));
$this->currentVote->neededPlayerRatio = floatval($this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_PLAYER_RATIO)); $this->currentVote->neededPlayerRatio = floatval($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_PLAYER_RATIO));
$this->currentVote->function = $function; $this->currentVote->function = $function;
if ($this->currentVote->voteCommand->startText != '') { if ($this->currentVote->voteCommand->startText != '') {
@ -499,25 +500,25 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
switch ($voteName) { switch ($voteName) {
case 'teambalance': case 'teambalance':
$this->maniaControl->client->autoTeamBalance(); $this->maniaControl->client->autoTeamBalance();
$this->maniaControl->chat->sendInformation('$f8fVote to $fffbalance the teams$f8f has been successfull!'); $this->maniaControl->chat->sendInformation('$f8fVote to $fffbalance the Teams$f8f has been successful!');
break; break;
case 'skipmap': case 'skipmap':
case 'skip': case 'skip':
case 'nextmap': case 'nextmap':
$this->maniaControl->mapManager->mapActions->skipMap(); $this->maniaControl->mapManager->mapActions->skipMap();
$this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the map$f8f has been successfull!'); $this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the Map$f8f has been successful!');
break; break;
case 'restartmap': case 'restartmap':
$this->maniaControl->client->restartMap(); $this->maniaControl->client->restartMap();
$this->maniaControl->chat->sendInformation('$f8fVote to $fffrestart the map$f8f has been successfull!'); $this->maniaControl->chat->sendInformation('$f8fVote to $fffrestart the Map$f8f has been successful!');
break; break;
case 'pausegame': case 'pausegame':
$this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); $this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => true));
$this->maniaControl->chat->sendInformation('$f8fVote to $fffpause the current game$f8f has been successfull!'); $this->maniaControl->chat->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!');
break; break;
case 'replay': case 'replay':
$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap()); $this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap());
$this->maniaControl->chat->sendInformation('$f8fVote to $fffreplay the map$f8f has been successfull!'); $this->maniaControl->chat->sendInformation('$f8fVote to $fffreplay the Map$f8f has been successful!');
break; break;
} }
} else { } else {
@ -545,6 +546,12 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
} }
} }
/**
* Handle a Player Chat Vote
*
* @param array $chat
* @param Player $player
*/
public function handleChatVote(array $chat, Player $player) { public function handleChatVote(array $chat, Player $player) {
$chatCommand = explode(' ', $chat[1][2]); $chatCommand = explode(' ', $chat[1][2]);
$chatCommand = $chatCommand[0]; $chatCommand = $chatCommand[0];
@ -571,7 +578,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
* @param Player $player * @param Player $player
*/ */
public function handlePositiveVote(array $callback, Player $player) { public function handlePositiveVote(array $callback, Player $player) {
if (!isset($this->currentVote) || $player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) { if (!isset($this->currentVote) || $player->isSpectator && !$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) {
return; return;
} }
@ -585,7 +592,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
* @param Player $player * @param Player $player
*/ */
public function handleNegativeVote(array $callback, Player $player) { public function handleNegativeVote(array $callback, Player $player) {
if (!isset($this->currentVote) || $player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) { if (!isset($this->currentVote) || $player->isSpectator && !$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) {
return; return;
} }
@ -621,17 +628,17 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
} }
/** /**
* Shows the vote widget * Show the vote widget
* *
* @param $timeUntilExpire * @param int $timeUntilExpire
* @param $votePercentage * @param float $votePercentage
*/ */
private function showVoteWidget($timeUntilExpire, $votePercentage) { private function showVoteWidget($timeUntilExpire, $votePercentage) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_HEIGHT);
$maxTime = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_TIME); $maxTime = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_TIME);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -755,7 +762,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
} }
/** /**
* Vote Command Structure * Vote Command Model Class
*/ */
class VoteCommand { class VoteCommand {
public $index = ''; public $index = '';
@ -764,6 +771,14 @@ class VoteCommand {
public $idBased = false; public $idBased = false;
public $startText = ''; public $startText = '';
/**
* Construct a new Vote Command
*
* @param $index
* @param $name
* @param $idBased
* @param $neededRatio
*/
public function __construct($index, $name, $idBased, $neededRatio) { public function __construct($index, $name, $idBased, $neededRatio) {
$this->index = $index; $this->index = $index;
$this->name = $name; $this->name = $name;
@ -773,7 +788,7 @@ class VoteCommand {
} }
/** /**
* Current Vote Structure * Current Vote Model Class
*/ */
class CurrentVote { class CurrentVote {
const VOTE_FOR_ACTION = '1'; const VOTE_FOR_ACTION = '1';
@ -791,6 +806,13 @@ class CurrentVote {
private $playersVoted = array(); private $playersVoted = array();
/**
* Construct a Current Vote
*
* @param VoteCommand $voteCommand
* @param Player $voter
* @param $expireTime
*/
public function __construct(VoteCommand $voteCommand, Player $voter, $expireTime) { public function __construct(VoteCommand $voteCommand, Player $voter, $expireTime) {
$this->expireTime = $expireTime; $this->expireTime = $expireTime;
$this->voteCommand = $voteCommand; $this->voteCommand = $voteCommand;
@ -798,6 +820,11 @@ class CurrentVote {
$this->votePositive($voter->login); $this->votePositive($voter->login);
} }
/**
* Handle a positive Vote
*
* @param string $login
*/
public function votePositive($login) { public function votePositive($login) {
if (isset($this->playersVoted[$login])) { if (isset($this->playersVoted[$login])) {
if ($this->playersVoted[$login] == self::VOTE_AGAINST_ACTION) { if ($this->playersVoted[$login] == self::VOTE_AGAINST_ACTION) {
@ -810,6 +837,11 @@ class CurrentVote {
} }
} }
/**
* Handle a negative Vote
*
* @param string $login
*/
public function voteNegative($login) { public function voteNegative($login) {
if (isset($this->playersVoted[$login])) { if (isset($this->playersVoted[$login])) {
if ($this->playersVoted[$login] == self::VOTE_FOR_ACTION) { if ($this->playersVoted[$login] == self::VOTE_FOR_ACTION) {
@ -821,6 +853,11 @@ class CurrentVote {
} }
} }
/**
* Get the Number of Votes
*
* @return int
*/
public function getVoteCount() { public function getVoteCount() {
return count($this->playersVoted); return count($this->playersVoted);
} }

View File

@ -156,7 +156,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
$packMask = substr($this->maniaControl->server->titleId, 2); $packMask = substr($this->maniaControl->server->titleId, 2);
} }
$dedimaniaCode = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l'); $dedimaniaCode = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l');
if ($dedimaniaCode == '') { if ($dedimaniaCode == '') {
throw new \Exception("No Dedimania Code Specified, check the settings!"); throw new \Exception("No Dedimania Code Specified, check the settings!");
} }
@ -403,7 +403,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
$this->updateManialink = false; $this->updateManialink = false;
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_ENABLE)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
$manialink = $this->buildManialink(); $manialink = $this->buildManialink();
$this->maniaControl->manialinkManager->sendManialink($manialink); $this->maniaControl->manialinkManager->sendManialink($manialink);
} }
@ -420,12 +420,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
} }
$records = $this->dedimaniaData->records; $records = $this->dedimaniaData->records;
$title = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_TITLE); $title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE);
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
$lines = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_LINESCOUNT); $lines = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINESCOUNT);
$lineHeight = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_LINEHEIGHT); $lineHeight = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINEHEIGHT);
$labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle(); $labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -582,7 +582,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
$self->fetchDedimaniaRecords(true); $self->fetchDedimaniaRecords(true);
} }
} }
if ($self->maniaControl->settingManager->getSetting($self, self::SETTING_WIDGET_ENABLE)) { if ($self->maniaControl->settingManager->getSettingValue($self, self::SETTING_WIDGET_ENABLE)) {
$manialink = $self->buildManialink(); $manialink = $self->buildManialink();
$self->maniaControl->manialinkManager->sendManialink($manialink, $player->login); $self->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
} }
@ -754,7 +754,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
} }
/** /**
* Build votes info struct for callbacks * Build Votes Info Array for Callbacks
*/ */
private function getVotesInfo() { private function getVotesInfo() {
$map = $this->maniaControl->mapManager->getCurrentMap(); $map = $this->maniaControl->mapManager->getCurrentMap();
@ -786,7 +786,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
} }
/** /**
* Plyer finished callback * Player finished callback
* *
* @param $callback * @param $callback
*/ */

View File

@ -109,7 +109,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$this->maniaControl->commandManager->registerCommandListener('donate', $this, 'command_Donate', false, 'Donate some planets to the server.'); $this->maniaControl->commandManager->registerCommandListener('donate', $this, 'command_Donate', false, 'Donate some planets to the server.');
$this->maniaControl->commandManager->registerCommandListener('pay', $this, 'command_Pay', true, 'Pays planets from the server to a player.'); $this->maniaControl->commandManager->registerCommandListener('pay', $this, 'command_Pay', true, 'Pays planets from the server to a player.');
$this->maniaControl->commandManager->registerCommandListener('planets', $this, 'command_GetPlanets', true, 'Checks the planets-balance of the server.'); $this->maniaControl->commandManager->registerCommandListener('planets', $this, 'command_GetPlanets', true, 'Checks the planets-balance of the server.');
$this->maniaControl->commandManager->registerCommandListener('topdons', $this, 'command_TopDons', false, 'Provides an overview of who dontated the most planets.'); $this->maniaControl->commandManager->registerCommandListener('topdons', $this, 'command_TopDons', false, 'Provides an overview of who donated the most planets.');
// Register for callbacks // Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
@ -137,7 +137,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
* Display the widget * Display the widget
*/ */
public function displayWidget() { public function displayWidget() {
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
$this->displayDonateWidget(); $this->displayDonateWidget();
} }
} }
@ -148,11 +148,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
* @param string $login * @param string $login
*/ */
public function displayDonateWidget($login = null) { public function displayDonateWidget($login = null) {
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_POSX); $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSX);
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_POSY); $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATE_WIDGET_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATE_WIDGET_HEIGHT);
$values = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATION_VALUES); $values = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATION_VALUES);
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM(); $shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -286,7 +286,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$self, &$player, $amount, $receiver) { $this->maniaControl->billManager->sendBill(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
switch ($status) { switch ($status) {
case BillManager::DONATED_TO_SERVER: case BillManager::DONATED_TO_SERVER:
if ($self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) { if ($self->maniaControl->settingManager->getSettingValue($self, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $self->maniaControl->settingManager->getSettingValue($self, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) {
$login = null; $login = null;
$message = '$<' . $player->nickname . '$> donated ' . $amount . ' Planets! Thanks.'; $message = '$<' . $player->nickname . '$> donated ' . $amount . ' Planets! Thanks.';
} else { } else {
@ -319,7 +319,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
// Display Map Widget // Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
$this->displayDonateWidget($player->login); $this->displayDonateWidget($player->login);
} }
} }

View File

@ -176,10 +176,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
//Check if Karma Code got specified, and inform admin that it would be good to specifiy one //Check if Karma Code got specified, and inform admin that it would be good to specifiy one
$serverLogin = $this->maniaControl->server->login; $serverLogin = $this->maniaControl->server->login;
$karmaSettingName = self::buildKarmaSettingName($serverLogin); $karmaSettingName = self::buildKarmaSettingName($serverLogin);
$mxKarmaCode = $this->maniaControl->settingManager->getSetting($this, $karmaSettingName); $mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
if ($mxKarmaCode == '') { if (!$mxKarmaCode) {
$permission = $this->maniaControl->settingManager->getSetting($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); $permission = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
$this->maniaControl->chat->sendErrorToAdmins("Please specify a Mania-Exchange Karma Key in the Karma-Plugin settings!", $permission); $this->maniaControl->chat->sendErrorToAdmins("Please specify a Mania-Exchange Karma Key in the Karma-Plugin settings!", $permission);
} }
@ -210,7 +210,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
// Migrate settings // Migrate settings
$this->maniaControl->database->migrationHelper->transferSettings('KarmaPlugin', $this); $this->maniaControl->database->migrationHelper->transferSettings('KarmaPlugin', $this);
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) { if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
return; return;
} }
@ -233,13 +233,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* Open a Mx Karma Session * Open a Mx Karma Session
*/ */
private function mxKarmaOpenSession() { private function mxKarmaOpenSession() {
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) { if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
return; return;
} }
$serverLogin = $this->maniaControl->server->login; $serverLogin = $this->maniaControl->server->login;
$karmaSettingName = self::buildKarmaSettingName($serverLogin); $karmaSettingName = self::buildKarmaSettingName($serverLogin);
$mxKarmaCode = $this->maniaControl->settingManager->getSetting($this, $karmaSettingName); $mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
if ($mxKarmaCode == '') { if ($mxKarmaCode == '') {
return; return;
@ -301,7 +301,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$self->getMxKarmaVotes(); $self->getMxKarmaVotes();
} else { } else {
if ($data->data->message == "invalid hash") { if ($data->data->message == "invalid hash") {
$permission = $self->maniaControl->settingManager->getSetting($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); $permission = $self->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
$self->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission); $self->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
} else { } else {
// TODO remove temp trigger // TODO remove temp trigger
@ -335,7 +335,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* Fetch the mxKarmaVotes for the current map * Fetch the mxKarmaVotes for the current map
*/ */
public function getMxKarmaVotes(Player $player = null) { public function getMxKarmaVotes(Player $player = null) {
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) { if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
return; return;
} }
@ -580,7 +580,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
*/ */
private function handleVote(Player $player, $vote) { private function handleVote(Player $player, $vote) {
// Check vote // Check vote
$votesSetting = $this->maniaControl->settingManager->getSetting($this, self::SETTING_AVAILABLE_VOTES); $votesSetting = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_AVAILABLE_VOTES);
$votes = explode(',', $votesSetting); $votes = explode(',', $votesSetting);
$voteLow = intval($votes[0]); $voteLow = intval($votes[0]);
$voteHigh = $voteLow + 2; $voteHigh = $voteLow + 2;
@ -600,7 +600,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$map = $this->maniaControl->mapManager->getCurrentMap(); $map = $this->maniaControl->mapManager->getCurrentMap();
// Update vote in MX karma array // Update vote in MX karma array
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED) && isset($this->mxKarma["session"])) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) && isset($this->mxKarma["session"])) {
if (!isset($this->mxKarma["votes"][$player->login])) { if (!isset($this->mxKarma["votes"][$player->login])) {
$sum = $this->mxKarma["voteCount"] * $this->mxKarma["voteAverage"] + $vote * 100; $sum = $this->mxKarma["voteCount"] * $this->mxKarma["voteAverage"] + $vote * 100;
$this->mxKarma["voteCount"]++; $this->mxKarma["voteCount"]++;
@ -765,7 +765,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
return; return;
} }
$displayMxKarma = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_DISPLAY_MX); $displayMxKarma = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_DISPLAY_MX);
// Get players // Get players
$players = $this->updateManialink; $players = $this->updateManialink;
@ -777,7 +777,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
// Get map karma // Get map karma
$map = $this->maniaControl->mapManager->getCurrentMap(); $map = $this->maniaControl->mapManager->getCurrentMap();
// Display the mx Karma if the setting is choosen and the MX session is available // Display the mx Karma if the setting is chosen and the MX session is available
if ($displayMxKarma && isset($this->mxKarma['session']) && isset($this->mxKarma['voteCount'])) { if ($displayMxKarma && isset($this->mxKarma['session']) && isset($this->mxKarma['voteCount'])) {
$karma = $this->mxKarma['modeVoteAverage'] / 100; $karma = $this->mxKarma['modeVoteAverage'] / 100;
$voteCount = $this->mxKarma['modeVoteCount']; $voteCount = $this->mxKarma['modeVoteCount'];
@ -787,7 +787,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$voteCount = $votes['count']; $voteCount = $votes['count'];
} }
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_ENABLE)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
// Build karma manialink // Build karma manialink
$this->buildManialink(); $this->buildManialink();
@ -893,11 +893,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
return; return;
} }
$title = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_TITLE); $title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE);
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH)->value;
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_HEIGHT)->value;
$labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle(); $labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -951,11 +951,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* @param Map $map * @param Map $map
*/ */
public function importMxKarmaVotes(Map $map) { public function importMxKarmaVotes(Map $map) {
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) { if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
return; return;
} }
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_IMPORTING)) { if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING)) {
return; return;
} }
@ -1008,7 +1008,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* Save Mx Karma Votes at Mapend * Save Mx Karma Votes at Mapend
*/ */
public function sendMxKarmaVotes(Map $map) { public function sendMxKarmaVotes(Map $map) {
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) { if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
return; return;
} }

View File

@ -192,7 +192,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
} }
$this->updateManialink = false; $this->updateManialink = false;
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_ENABLE)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
$manialink = $this->buildManialink(); $manialink = $this->buildManialink();
$this->maniaControl->manialinkManager->sendManialink($manialink); $this->maniaControl->manialinkManager->sendManialink($manialink);
} }
@ -209,12 +209,12 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
return null; return null;
} }
$title = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_TITLE); $title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE);
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
$lines = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_LINESCOUNT); $lines = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINESCOUNT);
$lineHeight = $this->maniaControl->settingManager->getSetting($this, self::SETTING_WIDGET_LINEHEIGHT); $lineHeight = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINEHEIGHT);
$labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle(); $labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -233,7 +233,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
$backgroundQuad->setVAlign(Control::TOP); $backgroundQuad->setVAlign(Control::TOP);
$adjustOuterBorder = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ADJUST_OUTER_BORDER); $adjustOuterBorder = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ADJUST_OUTER_BORDER);
$height = 7. + ($adjustOuterBorder ? count($records) : $lines) * $lineHeight; $height = 7. + ($adjustOuterBorder ? count($records) : $lines) * $lineHeight;
$backgroundQuad->setSize($width * 1.05, $height); $backgroundQuad->setSize($width * 1.05, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);
@ -448,8 +448,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
// Announce record // Announce record
$newRecord = $this->getLocalRecord($map, $player); $newRecord = $this->getLocalRecord($map, $player);
$notifyOnlyDriver = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER); $notifyOnlyDriver = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NOTIFY_ONLY_DRIVER);
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_BEST_RECORDS); $notifyOnlyBestRecords = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS);
if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) { if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) {
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved your'); $improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved your');
$message = 'You ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>'; $message = 'You ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';

View File

@ -119,7 +119,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
} }
//Check if the type is Correct //Check if the type is Correct
$type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE); $type = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_RANKING_TYPE);
if ($type != self::RANKING_TYPE_RECORDS && $type != self::RANKING_TYPE_POINTS && $type != self::RANKING_TYPE_RATIOS) { if ($type != self::RANKING_TYPE_RECORDS && $type != self::RANKING_TYPE_POINTS && $type != self::RANKING_TYPE_RATIOS) {
$error = 'Ranking Type is not correct, possible values(' . self::RANKING_TYPE_RATIOS . ', ' . self::RANKING_TYPE_POINTS . ', ' . self::RANKING_TYPE_POINTS . ')'; $error = 'Ranking Type is not correct, possible values(' . self::RANKING_TYPE_RATIOS . ', ' . self::RANKING_TYPE_POINTS . ', ' . self::RANKING_TYPE_POINTS . ')';
throw new \Exception($error); throw new \Exception($error);
@ -163,11 +163,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
// Erase old Average Data // Erase old Average Data
$mysqli->query('TRUNCATE TABLE ' . self::TABLE_RANK); $mysqli->query('TRUNCATE TABLE ' . self::TABLE_RANK);
$type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE); $type = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_RANKING_TYPE);
switch ($type) { switch ($type) {
case self::RANKING_TYPE_RATIOS: case self::RANKING_TYPE_RATIOS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING); $minHits = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_HITS_RATIO_RANKING);
$hits = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); $hits = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits);
$killDeathRatios = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_KD_RATIO); $killDeathRatios = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_KD_RATIO);
@ -187,7 +187,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
break; break;
case self::RANKING_TYPE_POINTS: case self::RANKING_TYPE_POINTS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING); $minHits = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING);
$ranks = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); $ranks = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits);
@ -197,8 +197,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
return; return;
} }
$requiredRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_REQUIRED_RECORDS); $requiredRecords = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_REQUIRED_RECORDS);
$maxRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAX_STORED_RECORDS); $maxRecords = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAX_STORED_RECORDS);
$query = 'SELECT playerIndex, COUNT(*) AS Cnt $query = 'SELECT playerIndex, COUNT(*) AS Cnt
FROM ' . \MCTeam\LocalRecordsPlugin::TABLE_RECORDS . ' FROM ' . \MCTeam\LocalRecordsPlugin::TABLE_RECORDS . '
@ -286,7 +286,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
public function showRank(Player $player) { public function showRank(Player $player) {
$rankObj = $this->getRank($player); $rankObj = $this->getRank($player);
$type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE); $type = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_RANKING_TYPE);
$message = ''; $message = '';
if ($rankObj) { if ($rankObj) {
@ -305,16 +305,16 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
} else { } else {
switch ($type) { switch ($type) {
case self::RANKING_TYPE_RATIOS: case self::RANKING_TYPE_RATIOS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING); $minHits = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_HITS_RATIO_RANKING);
$message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...'; $message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...';
break; break;
case self::RANKING_TYPE_POINTS: case self::RANKING_TYPE_POINTS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING); $minPoints = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING);
$message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...'; $message = '$0f3 You must make $<$fff' . $minPoints . '$> Hits on this server before receiving a rank...';
break; break;
case self::RANKING_TYPE_RECORDS: case self::RANKING_TYPE_RECORDS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_REQUIRED_RECORDS); $minRecords = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_REQUIRED_RECORDS);
$message = '$0f3 You need $<$fff' . $minHits . '$> Records on this server before receiving a rank...'; $message = '$0f3 You need $<$fff' . $minRecords . '$> Records on this server before receiving a rank...';
} }
} }
$this->maniaControl->chat->sendChat($message, $player->login); $this->maniaControl->chat->sendChat($message, $player->login);

View File

@ -165,14 +165,14 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
*/ */
private function displayWidgets() { private function displayWidgets() {
// Display Map Widget // Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->maniaControl->client->triggerModeScriptEventArray("Siege_SetProgressionLayerPosition", array("160.", "-67.", "0.")); $this->maniaControl->client->triggerModeScriptEventArray("Siege_SetProgressionLayerPosition", array("160.", "-67.", "0."));
$this->displayMapWidget(); $this->displayMapWidget();
} }
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
$this->displayClockWidget(); $this->displayClockWidget();
} }
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget(); $this->displayServerInfoWidget();
} }
} }
@ -183,10 +183,10 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
* @param string $login * @param string $login
*/ */
public function displayMapWidget($login = null) { public function displayMapWidget($login = null) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -254,10 +254,10 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
* @param bool $login * @param bool $login
*/ */
public function displayClockWidget($login = false) { public function displayClockWidget($login = false) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -295,10 +295,10 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
* @param string $login * @param string $login
*/ */
public function displayServerInfoWidget($login = null) { public function displayServerInfoWidget($login = null) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
@ -422,7 +422,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
*/ */
public function handleOnBeginMap(Map $map) { public function handleOnBeginMap(Map $map) {
// Display Map Widget // Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget(); $this->displayMapWidget();
} }
$this->closeWidget(self::MLID_NEXTMAPWIDGET); $this->closeWidget(self::MLID_NEXTMAPWIDGET);
@ -435,21 +435,21 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
*/ */
public function handleOnEndMap(Map $map) { public function handleOnEndMap(Map $map) {
// Display Map Widget // Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
$this->displayNextMapWidget(); $this->displayNextMapWidget();
} }
} }
/** /**
* Displays the Next Map (Only at the end of the Map) * Display the Next Map (Only at the end of the Map)
* *
* @param bool $login * @param string $login
*/ */
public function displayNextMapWidget($login = false) { public function displayNextMapWidget($login = null) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_POSX); $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_POSY); $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_WIDTH); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_WIDTH);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle(); $labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle();
@ -545,13 +545,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
// Display Map Widget // Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget($player->login); $this->displayMapWidget($player->login);
} }
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
$this->displayClockWidget($player->login); $this->displayClockWidget($player->login);
} }
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget(); $this->displayServerInfoWidget();
} }
} }
@ -562,7 +562,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
* @param Player $player * @param Player $player
*/ */
public function handlePlayerDisconnect(Player $player) { public function handlePlayerDisconnect(Player $player) {
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget(); $this->displayServerInfoWidget();
} }
} }

View File

@ -59,7 +59,7 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
public function load(ManiaControl $maniaControl) { public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$allowOthers = $this->maniaControl->settingManager->getSetting($this, self::ACCEPT_OTHER_MODES); $allowOthers = $this->maniaControl->settingManager->getSettingValue($this, self::ACCEPT_OTHER_MODES);
if (!$allowOthers && $this->maniaControl->server->titleId != 'SMStormRoyal@nadeolabs') { if (!$allowOthers && $this->maniaControl->server->titleId != 'SMStormRoyal@nadeolabs') {
$error = 'This plugin only supports Royal (check Settings)!'; $error = 'This plugin only supports Royal (check Settings)!';
throw new \Exception($error); throw new \Exception($error);
@ -138,10 +138,10 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
} }
} }
$pointlimit = ($numberOfPlayers * $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MULTIPLIER)) + $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_OFFSET); $pointlimit = ($numberOfPlayers * $this->maniaControl->settingManager->getSettingValue($this, self::DYNPNT_MULTIPLIER)) + $this->maniaControl->settingManager->getSettingValue($this, self::DYNPNT_OFFSET);
$min_value = $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MIN); $min_value = $this->maniaControl->settingManager->getSettingValue($this, self::DYNPNT_MIN);
$max_value = $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MAX); $max_value = $this->maniaControl->settingManager->getSettingValue($this, self::DYNPNT_MAX);
if ($pointlimit < $min_value) { if ($pointlimit < $min_value) {
$pointlimit = $min_value; $pointlimit = $min_value;
} }

View File

@ -64,59 +64,6 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
// TODO: Implement prepare() method. // TODO: Implement prepare() method.
} }
/**
* Load the plugin
*
* @param ManiaControl $maniaControl
* @return bool
*/
public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->maniaControl->timerManager->registerTimerListening($this, 'handleEverySecond', 1000);
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChanged');
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_ADDTOQUEUE, $this, 'handleManiaLinkAnswerAdd');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_REMOVEFROMQUEUE, $this, 'handleManiaLinkAnswerRemove');
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_MAX, 8);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_WIDGET_POS_X, 0);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_WIDGET_POS_Y, -46);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_ACTIVE_ON_PASS, false);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_CHATMESSAGES, true);
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue'];
if (!($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false)) {
foreach($this->maniaControl->playerManager->getPlayers() as $player) {
if ($player->isSpectator) {
$this->spectators[$player->login] = $player->login;
$this->maniaControl->client->forceSpectator($player->login, 1);
$this->showJoinQueueWidget($player);
}
}
}
}
/**
* Unload the plugin and its resources
*/
public function unload() {
foreach($this->spectators as $spectator) {
$this->maniaControl->client->forceSpectator($spectator, 3);
$this->maniaControl->client->forceSpectator($spectator, 0);
}
$this->maniaControl->manialinkManager->hideManialink(self::ML_ID);
$this->queue = array();
$this->spectators = array();
$this->showPlay = array();
}
/** /**
* Get plugin id * Get plugin id
* *
@ -162,13 +109,156 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
return 'Plugin offers the known AutoQueue/SpecJam options.'; return 'Plugin offers the known AutoQueue/SpecJam options.';
} }
/**
* Load the plugin
*
* @param ManiaControl $maniaControl
* @return bool
*/
public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->maniaControl->timerManager->registerTimerListening($this, 'handleEverySecond', 1000);
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChanged');
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_ADDTOQUEUE, $this, 'handleManiaLinkAnswerAdd');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_REMOVEFROMQUEUE, $this, 'handleManiaLinkAnswerRemove');
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_MAX, 8);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_WIDGET_POS_X, 0);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_WIDGET_POS_Y, -46);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_ACTIVE_ON_PASS, false);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_CHATMESSAGES, true);
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue'];
if (!($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false)) {
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
if ($player->isSpectator) {
$this->spectators[$player->login] = $player->login;
$this->maniaControl->client->forceSpectator($player->login, 1);
$this->showJoinQueueWidget($player);
}
}
}
}
/**
* Function shows the join queue widget to a player.
*
* @param Player $player
*/
private function showJoinQueueWidget(Player $player) {
$maniaLink = new ManiaLink(self::ML_ID);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
$maxQueue = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_MAX);
// Main frame
$frame = new Frame();
$maniaLink->add($frame);
$frame->setSize(60, 6);
$xPos = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_WIDGET_POS_X);
$yPos = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_WIDGET_POS_Y);
$frame->setPosition($xPos, $yPos, 0);
// Background
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setPosition(0, 0, 0);
$backgroundQuad->setSize(70, 10);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$cameraQuad = new Quad_Icons64x64_1();
$frame->add($cameraQuad);
$cameraQuad->setPosition(-29, 0.4, 2);
$cameraQuad->setSize(9, 9);
$cameraQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_Camera);
$statusLabel = new Label_Text();
$frame->add($statusLabel);
$statusLabel->setPosition(4.5, 2.8, 1);
$statusLabel->setSize(66, 4);
$statusLabel->setAlign('center', 'center');
$statusLabel->setScale(0.8);
$statusLabel->setStyle(Label_Text::STYLE_TextStaticSmall);
$messageLabel = new Label_Button();
$frame->add($messageLabel);
$messageLabel->setPosition(4.5, -1.6, 1);
$messageLabel->setSize(56, 4);
$messageLabel->setAlign('center', 'center');
$messageLabel->setScale(1.0);
$inQueue = false;
foreach ($this->queue as $queuedPlayer) {
if ($queuedPlayer->login == $player->login) {
$inQueue = true;
}
}
if ($inQueue) {
$message = '$fff$sYou\'re in the queue (click to unqueue).';
$position = 0;
foreach (array_values($this->queue) as $i => $queuePlayer) {
if ($player->login == $queuePlayer->login) {
$position = ($i + 1);
}
}
$statusLabel->setText('$aaaStatus: In queue (' . $position . '/' . count($this->queue) . ') Waiting: ' . count($this->queue) . '/' . $maxQueue . '');
$messageLabel->setAction(self::ML_REMOVEFROMQUEUE);
$backgroundQuad->setAction(self::ML_REMOVEFROMQUEUE);
$statusLabel->setAction(self::ML_REMOVEFROMQUEUE);
$cameraQuad->setAction(self::ML_REMOVEFROMQUEUE);
} else {
if (count($this->queue) < $maxQueue) {
$message = '$0ff$sClick to join spectator waiting list.';
$messageLabel->setAction(self::ML_ADDTOQUEUE);
$backgroundQuad->setAction(self::ML_ADDTOQUEUE);
$statusLabel->setAction(self::ML_ADDTOQUEUE);
$cameraQuad->setAction(self::ML_ADDTOQUEUE);
} else {
$message = '$f00The waiting list is full!';
}
$statusLabel->setText('$aaaStatus: Not queued spectator Waiting: ' . count($this->queue) . '/' . $maxQueue . '');
}
$messageLabel->setText($message);
$messageLabel->setStyle(Label_Text::STYLE_TextStaticSmall);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
}
/**
* Unload the plugin and its resources
*/
public function unload() {
foreach ($this->spectators as $spectator) {
$this->maniaControl->client->forceSpectator($spectator, 3);
$this->maniaControl->client->forceSpectator($spectator, 0);
}
$this->maniaControl->manialinkManager->hideManialink(self::ML_ID);
$this->queue = array();
$this->spectators = array();
$this->showPlay = array();
}
/** /**
* Function handling on the connection of a player. * Function handling on the connection of a player.
* *
* @param Player $player * @param Player $player
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) { if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return; return;
} }
@ -194,7 +284,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* @param Player $player * @param Player $player
*/ */
public function handlePlayerDisconnect(Player $player) { public function handlePlayerDisconnect(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) { if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return; return;
} }
@ -209,45 +299,23 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
} }
/** /**
* Function handling the change of player information. * Function removes a player from the queue.
* *
* @param array $callback * @param $login
*/ */
public function handlePlayerInfoChanged(array $callback) { private function removePlayerFromQueue($login) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) { $count = 0;
return; $newQueue = array();
foreach ($this->queue as $queuePlayer) {
if ($queuePlayer->login != $login) {
$newQueue[$count] = $queuePlayer;
$count++;
}
} }
$login = $callback[1][0]['Login']; $this->queue = $newQueue;
$player = $this->maniaControl->playerManager->getPlayer($login);
if (!is_null($player)) {
if ($player->isSpectator) {
if (!isset($this->spectators[$player->login])) {
$this->maniaControl->client->forceSpectator($player->login, 1);
$this->spectators[$player->login] = $player->login;
$this->showJoinQueueWidget($player);
$this->showQueueWidgetSpectators(); $this->showQueueWidgetSpectators();
} }
} else {
$this->removePlayerFromQueue($player->login);
if (isset($this->spectators[$player->login])) {
unset($this->spectators[$player->login]);
}
$found = false;
foreach($this->showPlay as $showPlay) {
if ($showPlay['player']->login == $player->login) {
$found = true;
}
}
if (!$found) {
$this->hideQueueWidget($player);
}
}
}
}
public function showQueueWidgetSpectators() { public function showQueueWidgetSpectators() {
foreach ($this->spectators as $login) { foreach ($this->spectators as $login) {
@ -256,63 +324,6 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
} }
} }
/**
* Function called on every second.
*/
public function handleEverySecond() {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
if ($this->maxPlayers > (count($this->maniaControl->playerManager->players) - count($this->spectators))) {
$this->moveFirstPlayerToPlay();
$this->showQueueWidgetSpectators();
}
foreach($this->showPlay as $showPlay) {
if (($showPlay['time'] + 5) < time()) {
$this->hideQueueWidget($showPlay['player']);
unset($this->showPlay[$showPlay['player']->login]);
}
}
}
/**
* Checks for being of new map to retrieve maximum number of players.
*
* @param $currentMap
*/
public function handleBeginMap($currentMap) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue'];
}
/**
* Function handling the click of the widget to add them to the queue.
*
* @param array $chatCallback
* @param Player $player
*/
public function handleManiaLinkAnswerAdd(array $chatCallback, Player $player) {
$this->addPlayerToQueue($player);
}
/**
* Function handling the click of the widget to remove them from the queue.
*
* @param array $chatCallback
* @param Player $player
*/
public function handleManiaLinkAnswerRemove(array $chatCallback, Player $player) {
$this->removePlayerFromQueue($player->login);
$this->showJoinQueueWidget($player);
$this->sendChatMessage('$<$fff' . $player->nickname . '$> has left the queue!');
}
/** /**
* Function used to move the first queued player to the * Function used to move the first queued player to the
*/ */
@ -330,7 +341,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* @param Player $player * @param Player $player
*/ */
private function forcePlayerToPlay(Player $player) { private function forcePlayerToPlay(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) { if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return; return;
} }
@ -386,152 +397,6 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
} }
/**
* Function adds a player to the queue.
*
* @param Player $player
* @return bool
*/
private function addPlayerToQueue(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return false;
}
foreach($this->queue as $queuedPlayer) {
if ($queuedPlayer->login == $player->login) {
$this->maniaControl->chat->sendError('You\'re already in the queue!', $player->login);
return false;
}
}
if ($this->maniaControl->settingManager->getSetting($this, self::QUEUE_MAX) > count($this->queue)) {
$this->queue[count($this->queue)] = $player;
$this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!');
}
$this->showQueueWidgetSpectators();
return true;
}
/**
* Function removes a player from the queue.
*
* @param $login
*/
private function removePlayerFromQueue($login) {
$count = 0;
$newQueue = array();
foreach($this->queue as $queuePlayer) {
if ($queuePlayer->login != $login) {
$newQueue[$count] = $queuePlayer;
$count++;
}
}
$this->queue = $newQueue;
$this->showQueueWidgetSpectators();
}
/**
* Function sends (or not depending on setting) chatmessages for the queue.
*
* @param $message
*/
private function sendChatMessage($message) {
if ($this->maniaControl->settingManager->getSetting($this, self::QUEUE_CHATMESSAGES)) {
$this->maniaControl->chat->sendChat('$090[Queue] ' . $message);
}
}
/**
* Function shows the join queue widget to a player.
*
* @param Player $player
*/
private function showJoinQueueWidget(Player $player) {
$maniaLink = new ManiaLink(self::ML_ID);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
$max_queue = $this->maniaControl->settingManager->getSetting($this, self::QUEUE_MAX);
// Main frame
$frame = new Frame();
$maniaLink->add($frame);
$frame->setSize(60, 6);
$frame->setPosition($this->maniaControl->settingManager->getSetting($this, self::QUEUE_WIDGET_POS_X), $this->maniaControl->settingManager->getSetting($this, self::QUEUE_WIDGET_POS_Y), 0);
// Background
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setPosition(0, 0, 0);
$backgroundQuad->setSize(70, 10);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$cameraQuad = new Quad_Icons64x64_1();
$frame->add($cameraQuad);
$cameraQuad->setPosition(-29, 0.4, 2);
$cameraQuad->setSize(9, 9);
$cameraQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_Camera);
$statusLabel = new Label_Text();
$frame->add($statusLabel);
$statusLabel->setPosition(4.5, 2.8, 1);
$statusLabel->setSize(66, 4);
$statusLabel->setAlign('center', 'center');
$statusLabel->setScale(0.8);
$statusLabel->setStyle(Label_Text::STYLE_TextStaticSmall);
$messageLabel = new Label_Button();
$frame->add($messageLabel);
$messageLabel->setPosition(4.5, -1.6, 1);
$messageLabel->setSize(56, 4);
$messageLabel->setAlign('center', 'center');
$messageLabel->setScale(1.0);
$inQueue = false;
foreach($this->queue as $queuedPlayer) {
if ($queuedPlayer->login == $player->login) {
$inQueue = true;
}
}
if ($inQueue) {
$message = '$fff$sYou\'re in the queue (click to unqueue).';
$position = 0;
foreach(array_values($this->queue) as $i => $queuePlayer) {
if ($player->login == $queuePlayer->login) {
$position = ($i + 1);
}
}
$statusLabel->setText('$aaaStatus: In queue (' . $position . '/' . count($this->queue) . ') Waiting: ' . count($this->queue) . '/' . $max_queue . '');
$messageLabel->setAction(self::ML_REMOVEFROMQUEUE);
$backgroundQuad->setAction(self::ML_REMOVEFROMQUEUE);
$statusLabel->setAction(self::ML_REMOVEFROMQUEUE);
$cameraQuad->setAction(self::ML_REMOVEFROMQUEUE);
} else {
if (count($this->queue) < $max_queue) {
$message = '$0ff$sClick to join spectator waiting list.';
$messageLabel->setAction(self::ML_ADDTOQUEUE);
$backgroundQuad->setAction(self::ML_ADDTOQUEUE);
$statusLabel->setAction(self::ML_ADDTOQUEUE);
$cameraQuad->setAction(self::ML_ADDTOQUEUE);
} else {
$message = '$f00The waiting list is full!';
}
$statusLabel->setText('$aaaStatus: Not queued spectator Waiting: ' . count($this->queue) . '/' . $max_queue . '');
}
$messageLabel->setText($message);
$messageLabel->setStyle(Label_Text::STYLE_TextStaticSmall);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
}
/** /**
* Function shows the "You got a free spot, enjoy playing!" widget. * Function shows the "You got a free spot, enjoy playing!" widget.
* *
@ -547,7 +412,9 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
$frame = new Frame(); $frame = new Frame();
$maniaLink->add($frame); $maniaLink->add($frame);
$frame->setSize(60, 6); $frame->setSize(60, 6);
$frame->setPosition($this->maniaControl->settingManager->getSetting($this, self::QUEUE_WIDGET_POS_X), $this->maniaControl->settingManager->getSetting($this, self::QUEUE_WIDGET_POS_Y), 0); $xPosSetting = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_WIDGET_POS_X);
$yPosSetting = $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_WIDGET_POS_Y);
$frame->setPosition($xPosSetting->value, $yPosSetting->value, 0);
// Background // Background
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
@ -575,6 +442,58 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
$this->showPlay[$player->login] = array('time' => time(), 'player' => $player); $this->showPlay[$player->login] = array('time' => time(), 'player' => $player);
} }
/**
* Function sends (or not depending on setting) chatmessages for the queue.
*
* @param $message
*/
private function sendChatMessage($message) {
if ($this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_CHATMESSAGES)) {
$this->maniaControl->chat->sendChat('$090[Queue] ' . $message);
}
}
/**
* Function handling the change of player information.
*
* @param array $callback
*/
public function handlePlayerInfoChanged(array $callback) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$login = $callback[1][0]['Login'];
$player = $this->maniaControl->playerManager->getPlayer($login);
if (!is_null($player)) {
if ($player->isSpectator) {
if (!isset($this->spectators[$player->login])) {
$this->maniaControl->client->forceSpectator($player->login, 1);
$this->spectators[$player->login] = $player->login;
$this->showJoinQueueWidget($player);
$this->showQueueWidgetSpectators();
}
} else {
$this->removePlayerFromQueue($player->login);
if (isset($this->spectators[$player->login])) {
unset($this->spectators[$player->login]);
}
$found = false;
foreach ($this->showPlay as $showPlay) {
if ($showPlay['player']->login == $player->login) {
$found = true;
}
}
if (!$found) {
$this->hideQueueWidget($player);
}
}
}
}
/** /**
* Function hides the queue widget from the player. * Function hides the queue widget from the player.
* *
@ -583,4 +502,89 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
private function hideQueueWidget(Player $player) { private function hideQueueWidget(Player $player) {
$this->maniaControl->manialinkManager->hideManialink(self::ML_ID, $player); $this->maniaControl->manialinkManager->hideManialink(self::ML_ID, $player);
} }
/**
* Function called on every second.
*/
public function handleEverySecond() {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
if ($this->maxPlayers > (count($this->maniaControl->playerManager->players) - count($this->spectators))) {
$this->moveFirstPlayerToPlay();
$this->showQueueWidgetSpectators();
}
foreach ($this->showPlay as $showPlay) {
if (($showPlay['time'] + 5) < time()) {
$this->hideQueueWidget($showPlay['player']);
unset($this->showPlay[$showPlay['player']->login]);
}
}
}
/**
* Checks for being of new map to retrieve maximum number of players.
*
* @param $currentMap
*/
public function handleBeginMap($currentMap) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue'];
}
/**
* Function handling the click of the widget to add them to the queue.
*
* @param array $chatCallback
* @param Player $player
*/
public function handleManiaLinkAnswerAdd(array $chatCallback, Player $player) {
$this->addPlayerToQueue($player);
}
/**
* Function adds a player to the queue.
*
* @param Player $player
* @return bool
*/
private function addPlayerToQueue(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return false;
}
foreach ($this->queue as $queuedPlayer) {
if ($queuedPlayer->login == $player->login) {
$this->maniaControl->chat->sendError('You\'re already in the queue!', $player->login);
return false;
}
}
if ($this->maniaControl->settingManager->getSettingValue($this, self::QUEUE_MAX) > count($this->queue)) {
$this->queue[count($this->queue)] = $player;
$this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!');
}
$this->showQueueWidgetSpectators();
return true;
}
/**
* Function handling the click of the widget to remove them from the queue.
*
* @param array $chatCallback
* @param Player $player
*/
public function handleManiaLinkAnswerRemove(array $chatCallback, Player $player) {
$this->removePlayerFromQueue($player->login);
$this->showJoinQueueWidget($player);
$this->sendChatMessage('$<$fff' . $player->nickname . '$> has left the queue!');
}
} }

View File

@ -97,7 +97,7 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
* @throws \Exception * @throws \Exception
*/ */
private function checkConfig() { private function checkConfig() {
if ($this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) == 'ts3.somehoster.com') { if ($this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERHOST) == 'ts3.somehoster.com') {
$error = 'Missing the required serverhost, please set it up before enabling the TeamSpeak plugin!'; $error = 'Missing the required serverhost, please set it up before enabling the TeamSpeak plugin!';
throw new \Exception($error); throw new \Exception($error);
} }
@ -271,9 +271,9 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
$joinbutton->setWidth(150); $joinbutton->setWidth(150);
$joinbutton->setY($height / 2 - 11.5); $joinbutton->setY($height / 2 - 11.5);
$joinbutton->setStyle($joinbutton::STYLE_CardButtonSmallWide); $joinbutton->setStyle($joinbutton::STYLE_CardButtonSmallWide);
$joinbutton->setText('Join TeamSpeak: ' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) . ':' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERPORT)); $joinbutton->setText('Join TeamSpeak: ' . $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERHOST) . ':' . $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERPORT));
$joinbutton->setTextColor('fff'); $joinbutton->setTextColor('fff');
$url = 'ts3server://' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST) . '/?port=' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERPORT) . '&nickname=' . rawurlencode(Formatter::stripCodes($player->nickname)); $url = 'ts3server://' . $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERHOST) . '/?port=' . $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERPORT) . '&nickname=' . rawurlencode(Formatter::stripCodes($player->nickname));
$joinbutton->setUrl($url); $joinbutton->setUrl($url);
$leftlistQuad = new Quad(); $leftlistQuad = new Quad();
@ -371,12 +371,13 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
if (time() >= $this->refreshTime) { if (time() >= $this->refreshTime) {
$this->refreshTime = (time() + $this->refreshInterval); $this->refreshTime = (time() + $this->refreshInterval);
$queryhost = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYHOST); $queryHost = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYHOST);
$host = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SERVERHOST); $host = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SERVERHOST);
$host = ($queryhost != '') ? $queryhost : $host; $host = ($queryHost != '') ? $queryHost : $host;
$queryPort = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYPORT);
$socket = fsockopen(@$host, $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYPORT), $errno, $errstr, 2); $socket = fsockopen(@$host, $queryPort, $errno, $errstr, 2);
if ($socket) { if ($socket) {
socket_set_timeout($socket, 2); socket_set_timeout($socket, 2);
$is_ts3 = trim(fgets($socket)) == 'TS3'; $is_ts3 = trim(fgets($socket)) == 'TS3';
@ -384,8 +385,8 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
trigger_error('[TeamSpeakPlugin] Server at "' . $host . '" is not a Teamspeak3-Server or you have setup a bad query-port!', E_USER_WARNING); trigger_error('[TeamSpeakPlugin] Server at "' . $host . '" is not a Teamspeak3-Server or you have setup a bad query-port!', E_USER_WARNING);
} }
$queryuser = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYUSER); $queryuser = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYUSER);
$querypass = $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_QUERYPASS); $querypass = $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_QUERYPASS);
if (($queryuser != '') && !is_numeric($queryuser) && $queryuser != false && ($querypass != '') && !is_numeric($querypass) && $querypass != false) { if (($queryuser != '') && !is_numeric($queryuser) && $queryuser != false && ($querypass != '') && !is_numeric($querypass) && $querypass != false) {
$ret = $this->ts3_sendCommand($socket, 'login client_login_name=' . $this->ts3_escape($queryuser) . ' client_login_password=' . $this->ts3_escape($querypass)); $ret = $this->ts3_sendCommand($socket, 'login client_login_name=' . $this->ts3_escape($queryuser) . ' client_login_password=' . $this->ts3_escape($querypass));
if (stripos($ret, "error id=0") === false) { if (stripos($ret, "error id=0") === false) {
@ -395,7 +396,7 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
} }
$response = ''; $response = '';
$response .= $this->ts3_sendCommand($socket, 'use sid=' . $this->maniaControl->settingManager->getSetting($this, self::TEAMSPEAK_SID)); $response .= $this->ts3_sendCommand($socket, 'use sid=' . $this->maniaControl->settingManager->getSettingValue($this, self::TEAMSPEAK_SID));
$this->ts3_sendCommand($socket, 'clientupdate client_nickname=' . $this->ts3_escape('ManiaControl Viewer')); $this->ts3_sendCommand($socket, 'clientupdate client_nickname=' . $this->ts3_escape('ManiaControl Viewer'));
$response .= $this->ts3_sendCommand($socket, 'serverinfo'); $response .= $this->ts3_sendCommand($socket, 'serverinfo');
$response .= $this->ts3_sendCommand($socket, 'channellist -topic -flags -voice -limits'); $response .= $this->ts3_sendCommand($socket, 'channellist -topic -flags -voice -limits');

View File

@ -9,7 +9,7 @@ use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception; use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
/** /**
* ManiaControl Obstacle Plugin * ManiaControl Obstacle Plugin
@ -110,7 +110,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
* @return bool * @return bool
*/ */
public function command_JumpTo(array $chatCallback, Player $player) { public function command_JumpTo(array $chatCallback, Player $player) {
$authLevel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_JUMPTOAUTHLEVEL); $authLevel = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_JUMPTOAUTHLEVEL);
if (!$this->maniaControl->authenticationManager->checkRight($player, $authLevel)) { if (!$this->maniaControl->authenticationManager->checkRight($player, $authLevel)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
@ -120,12 +120,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
$param = $player->login . ";" . $params[1] . ";"; $param = $player->login . ";" . $params[1] . ";";
try { try {
$this->maniaControl->client->triggerModeScriptEvent(self::CB_JUMPTO, $param); $this->maniaControl->client->triggerModeScriptEvent(self::CB_JUMPTO, $param);
} catch (Exception $e) { } catch (NotInScriptModeException $e) {
if ($e->getMessage() == 'Not in script mode.') {
trigger_error("Couldn't send jump callback for '{$player->login}'. " . $e->getMessage());
return;
}
throw $e;
} }
} }