From ec226105e41a68b48f87935e85266e9c2f11b6f1 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 9 Jun 2015 11:23:57 +0200 Subject: [PATCH] Added support for overriding properties over the command line --- src/pocketmine/Server.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 45243a05d..1e18e2810 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -240,6 +240,8 @@ class Server{ /** @var Config */ private $properties; + private $propertyCache = []; + /** @var Config */ private $config; @@ -1307,9 +1309,16 @@ class Server{ * @return mixed */ 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]; } /**