mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
parent
7864294336
commit
9a0ead6deb
@ -201,6 +201,24 @@ JIT_WARNING
|
|||||||
ini_set('assert.exception', '1');
|
ini_set('assert.exception', '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getopt_string(string $opt) : ?string{
|
||||||
|
$opts = getopt("", ["$opt:"]);
|
||||||
|
if(isset($opts[$opt])){
|
||||||
|
if(is_string($opts[$opt])){
|
||||||
|
return $opts[$opt];
|
||||||
|
}
|
||||||
|
if(is_array($opts[$opt])){
|
||||||
|
critical_error("Cannot specify --$opt multiple times");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if($opts[$opt] === false){
|
||||||
|
critical_error("Missing value for --$opt");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -252,16 +270,22 @@ JIT_WARNING
|
|||||||
|
|
||||||
ErrorToExceptionHandler::set();
|
ErrorToExceptionHandler::set();
|
||||||
|
|
||||||
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
|
|
||||||
|
|
||||||
$cwd = Utils::assumeNotFalse(realpath(Utils::assumeNotFalse(getcwd())));
|
$cwd = Utils::assumeNotFalse(realpath(Utils::assumeNotFalse(getcwd())));
|
||||||
$dataPath = isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : $cwd . DIRECTORY_SEPARATOR;
|
$dataPath = getopt_string("data") ?? $cwd;
|
||||||
$pluginPath = isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : $cwd . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR;
|
$pluginPath = getopt_string("plugins") ?? $cwd . DIRECTORY_SEPARATOR . "plugins";
|
||||||
Filesystem::addCleanedPath($pluginPath, Filesystem::CLEAN_PATH_PLUGINS_PREFIX);
|
Filesystem::addCleanedPath($pluginPath, Filesystem::CLEAN_PATH_PLUGINS_PREFIX);
|
||||||
|
|
||||||
if(!file_exists($dataPath)){
|
if(!@mkdir($dataPath, 0777, true) && (!is_dir($dataPath) || !is_writable($dataPath))){
|
||||||
mkdir($dataPath, 0777, true);
|
critical_error("Unable to create/access data directory at $dataPath. Check that the target location is accessible by the current user.");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
//this has to be done after we're sure the data path exists
|
||||||
|
$dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
|
||||||
|
if(!@mkdir($pluginPath, 0777, true) && (!is_dir($pluginPath) || !is_writable($pluginPath))){
|
||||||
|
critical_error("Unable to create plugin directory at $pluginPath. Check that the target location is accessible by the current user.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
$lockFilePath = Path::join($dataPath, 'server.lock');
|
$lockFilePath = Path::join($dataPath, 'server.lock');
|
||||||
if(($pid = Filesystem::createLockFile($lockFilePath)) !== null){
|
if(($pid = Filesystem::createLockFile($lockFilePath)) !== null){
|
||||||
@ -273,6 +297,7 @@ JIT_WARNING
|
|||||||
//Logger has a dependency on timezone
|
//Logger has a dependency on timezone
|
||||||
Timezone::init();
|
Timezone::init();
|
||||||
|
|
||||||
|
$opts = getopt("", ["no-wizard", "enable-ansi", "disable-ansi"]);
|
||||||
if(isset($opts["enable-ansi"])){
|
if(isset($opts["enable-ansi"])){
|
||||||
Terminal::init(true);
|
Terminal::init(true);
|
||||||
}elseif(isset($opts["disable-ansi"])){
|
}elseif(isset($opts["disable-ansi"])){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user