From 7ed2fe4d74bbd89d57ec1b2e4821e33f87052a41 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 15 May 2017 19:30:22 +0200 Subject: [PATCH] directory name changes + new functions --- core/Maps/DirectoryBrowser.php | 4 +-- core/Server/Directory.php | 26 +++++++++++++++++--- core/Server/Server.php | 2 +- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/core/Maps/DirectoryBrowser.php b/core/Maps/DirectoryBrowser.php index e1e0005f..233144df 100644 --- a/core/Maps/DirectoryBrowser.php +++ b/core/Maps/DirectoryBrowser.php @@ -112,7 +112,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $isInMapsFolder = ($mapsDir === $folderDir); break; case 'UserData': - $dataDir = dirname($this->maniaControl->getServer()->getDirectory()->getGameDataFolder()); + $dataDir = dirname($this->maniaControl->getServer()->getDirectory()->getUserDataFolder()); $folderDir = dirname($folderPath); if ($dataDir === $folderDir) { // Prevent navigation out of maps directory @@ -152,7 +152,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $directoryLabel = new Label_Text(); $frame->addChild($directoryLabel); - $dataFolder = $this->maniaControl->getServer()->getDirectory()->getGameDataFolder(); + $dataFolder = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder(); $directoryText = substr($folderPath, strlen($dataFolder)); $directoryLabel->setPosition($width * -0.41, $height * 0.45)->setSize($width * 0.85, 4)->setHorizontalAlign($directoryLabel::LEFT)->setText($directoryText)->setTextSize(2); diff --git a/core/Server/Directory.php b/core/Server/Directory.php index 29a48b4b..49ac3741 100644 --- a/core/Server/Directory.php +++ b/core/Server/Directory.php @@ -78,18 +78,36 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getLogsFolder() { - return $this->getGameDataFolder() . '..' . DIRECTORY_SEPARATOR . 'Logs' . DIRECTORY_SEPARATOR; + return $this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'Logs' . DIRECTORY_SEPARATOR; } /** - * Retrieve the Game Data Folder Path + * Retrieve the GameData Folder Path * * @return string */ - public function getGameDataFolder() { + public function getGameDataFolder(){ + return $this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'GameData' . DIRECTORY_SEPARATOR; + } + + /** + * Retrieve the User Data Folder Path + * + * @return string + */ + public function getUserDataFolder() { return $this->maniaControl->getClient()->gameDataDirectory(); } + /** + * Retrieve the Scripts Folder Path + * + * @return string + */ + public function getScriptsFolder(){ + return $this->getGameDataFolder() . 'Scripts' . DIRECTORY_SEPARATOR; + } + /** * @return bool */ @@ -103,6 +121,6 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getCacheFolder() { - return $this->getGameDataFolder() . '..' . DIRECTORY_SEPARATOR . 'CommonData' . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR; + return $this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'CommonData' . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR; } } diff --git a/core/Server/Server.php b/core/Server/Server.php index 512eab14..2d93998d 100644 --- a/core/Server/Server.php +++ b/core/Server/Server.php @@ -347,7 +347,7 @@ class Server implements CallbackListener, CommandListener, UsageInformationAble * @return string */ public function getGhostReplay($login) { - $dataDir = $this->getDirectory()->getGameDataFolder(); + $dataDir = $this->getDirectory()->getUserDataFolder(); if (!$this->checkAccess($dataDir)) { return null; } diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 5abc6ba4..1c489f2e 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -1115,7 +1115,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene // Set ghost replay if ($record->rank <= 1) { - $dataDirectory = $this->maniaControl->getServer()->getDirectory()->getGameDataFolder(); + $dataDirectory = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder(); if (!isset($this->dedimaniaData->directoryAccessChecked)) { $access = $this->maniaControl->getServer()->checkAccess($dataDirectory); if (!$access) {