mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Store plugin data in <data path>/plugin_data in new installations
This will preserve the old behaviour for existing installations.
This commit is contained in:
parent
b0780c4d1d
commit
fe29b89fd1
@ -1636,7 +1636,7 @@ class Server{
|
||||
|
||||
$this->resourceManager = new ResourcePackManager($this->getDataPath() . "resource_packs" . DIRECTORY_SEPARATOR, $this->logger);
|
||||
|
||||
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
||||
$this->pluginManager = new PluginManager($this, $this->commandMap, ((bool) $this->getProperty("plugins.legacy-data-dir", true)) ? null : $this->getDataPath() . "plugin_data" . DIRECTORY_SEPARATOR);
|
||||
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
||||
$this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20);
|
||||
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
|
||||
|
@ -94,16 +94,28 @@ class PluginManager{
|
||||
/** @var int */
|
||||
private $eventCallDepth = 0;
|
||||
|
||||
/** @var string|null */
|
||||
private $pluginDataDirectory;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $pluginParentTimer;
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param SimpleCommandMap $commandMap
|
||||
* @param null|string $pluginDataDirectory
|
||||
*/
|
||||
public function __construct(Server $server, SimpleCommandMap $commandMap){
|
||||
public function __construct(Server $server, SimpleCommandMap $commandMap, ?string $pluginDataDirectory){
|
||||
$this->server = $server;
|
||||
$this->commandMap = $commandMap;
|
||||
$this->pluginDataDirectory = $pluginDataDirectory;
|
||||
if($this->pluginDataDirectory !== null){
|
||||
if(!file_exists($this->pluginDataDirectory)){
|
||||
@mkdir($this->pluginDataDirectory, 0777, true);
|
||||
}elseif(!is_dir($this->pluginDataDirectory)){
|
||||
throw new \RuntimeException("Plugin data path $this->pluginDataDirectory exists and is not a directory");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,6 +145,13 @@ class PluginManager{
|
||||
return $this->plugins;
|
||||
}
|
||||
|
||||
private function getDataDirectory(string $pluginPath, string $pluginName) : string{
|
||||
if($this->pluginDataDirectory !== null){
|
||||
return $this->pluginDataDirectory . $pluginName;
|
||||
}
|
||||
return dirname($pluginPath) . DIRECTORY_SEPARATOR . $pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param PluginLoader[] $loaders
|
||||
@ -152,7 +171,7 @@ class PluginManager{
|
||||
return null;
|
||||
}
|
||||
|
||||
$dataFolder = dirname($path) . DIRECTORY_SEPARATOR . $description->getName();
|
||||
$dataFolder = $this->getDataDirectory($path, $description->getName());
|
||||
if(file_exists($dataFolder) and !is_dir($dataFolder)){
|
||||
$this->server->getLogger()->error("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory");
|
||||
return null;
|
||||
|
@ -196,3 +196,9 @@ worlds:
|
||||
#world:
|
||||
# seed: 404
|
||||
# generator: FLAT:2;7,59x1,3x3,2;1;decoration(treecount=80 grasscount=45)
|
||||
|
||||
plugins:
|
||||
#Setting this to true will cause the legacy structure to be used where plugin data is placed inside the --plugins dir.
|
||||
#False will place plugin data under plugin_data under --data.
|
||||
#This option exists for backwards compatibility with existing installations.
|
||||
legacy-data-dir: false
|
||||
|
Loading…
x
Reference in New Issue
Block a user