public function forceShutdown()
{
if ($this->hasStopped) {
return;
}
try {
$this->hasStopped = true;
$this->shutdown();
if ($this->rcon instanceof RCON) {
$this->rcon->stop();
}
if ($this->getProperty("settings.upnp-forwarding", false) === true) {
$this->logger->info("[UPnP] Removing port forward...");
UPnP::RemovePortForward($this->getPort());
}
$this->pluginManager->disablePlugins();
foreach ($this->players as $player) {
$player->close(TextFormat::YELLOW . $player->getName() . " has left the game", $this->getProperty("settings.shutdown-message", "Server closed"));
}
foreach ($this->getLevels() as $level) {
$this->unloadLevel($level, true);
}
if ($this->generationManager instanceof GenerationRequestManager) {
$this->generationManager->shutdown();
}
HandlerList::unregisterAll();
$this->scheduler->cancelAllTasks();
$this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
$this->properties->save();
$this->console->kill();
foreach ($this->network->getInterfaces() as $interface) {
$interface->shutdown();
$this->network->unregisterInterface($interface);
}
} catch (\Exception $e) {
$this->logger->emergency("Crashed while crashing, killing process");
@kill(getmypid());
}
}