Server: Prevent construction of more than one server instance at a time

I have no idea when one might choose to do this, but it could cause extremely undesirable effects, so it should be prevented.
This commit is contained in:
Dylan K. Taylor 2018-01-06 14:58:51 +00:00
parent 266a253c03
commit 6772a69c55

View File

@ -1434,6 +1434,9 @@ class Server{
* @param string $pluginPath
*/
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, string $dataPath, string $pluginPath){
if(self::$instance !== null){
throw new \InvalidStateException("Only one server instance can exist at once");
}
self::$instance = $this;
self::$sleeper = new \Threaded;
$this->autoloader = $autoloader;