mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Added support for overriding properties over the command line
This commit is contained in:
parent
2a1a09a923
commit
ec226105e4
@ -240,6 +240,8 @@ class Server{
|
|||||||
/** @var Config */
|
/** @var Config */
|
||||||
private $properties;
|
private $properties;
|
||||||
|
|
||||||
|
private $propertyCache = [];
|
||||||
|
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
@ -1307,9 +1309,16 @@ class Server{
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getProperty($variable, $defaultValue = null){
|
public function getProperty($variable, $defaultValue = null){
|
||||||
$value = $this->config->getNested($variable);
|
if(!array_key_exists($variable, $this->propertyCache)){
|
||||||
|
$v = getopt("", ["$variable::"]);
|
||||||
|
if(isset($v[$variable])){
|
||||||
|
$this->propertyCache[$variable] = $v[$variable];
|
||||||
|
}else{
|
||||||
|
$this->propertyCache[$variable] = $this->properties->getNested($variable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $value === null ? $defaultValue : $value;
|
return $this->propertyCache[$variable] === null ? $defaultValue : $this->propertyCache[$variable];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user