diff --git a/src/pocketmine/utils/ServerKiller.php b/src/pocketmine/utils/ServerKiller.php index 55dd2466b..27e690b1d 100644 --- a/src/pocketmine/utils/ServerKiller.php +++ b/src/pocketmine/utils/ServerKiller.php @@ -29,6 +29,9 @@ class ServerKiller extends Thread{ public $time; + /** @var bool */ + private $stopped = false; + public function __construct($time = 15){ $this->time = $time; } @@ -37,7 +40,9 @@ class ServerKiller extends Thread{ $this->registerClassLoader(); $start = time(); $this->synchronized(function(){ - $this->wait($this->time * 1000000); + if(!$this->stopped){ + $this->wait($this->time * 1000000); + } }); if(time() - $start >= $this->time){ echo "\nTook too long to stop, server was killed forcefully!\n"; @@ -45,6 +50,14 @@ class ServerKiller extends Thread{ } } + public function quit() : void{ + $this->synchronized(function() : void{ + $this->stopped = true; + $this->notify(); + }); + parent::quit(); + } + public function getThreadName() : string{ return "Server Killer"; }