Ejemplo n.º 1
0
 public function forceShutdown()
 {
     if ($this->hasStopped) {
         return;
     }
     try {
         $this->hasStopped = true;
         $this->shutdown();
         if ($this->rcon instanceof RCON) {
             $this->rcon->stop();
         }
         if ($this->getProperty("network.upnp-forwarding", false) === true) {
             $this->katana->console->system("[UPnP] Removing port forward...");
             UPnP::RemovePortForward($this->getPort());
         }
         $this->katana->console->system(Terminal::$COLOR_GRAY . "Disabling all plugins");
         $this->pluginManager->disablePlugins();
         foreach ($this->players as $player) {
             $player->close($player->getLeaveMessage(), $this->getProperty("settings.shutdown-message", "Server closed"));
         }
         $this->katana->console->system(Terminal::$COLOR_GRAY . "Unloading all levels");
         foreach ($this->getLevels() as $level) {
             $this->unloadLevel($level, true);
         }
         $this->katana->console->system("Removing event handlers");
         HandlerList::unregisterAll();
         $this->katana->console->system("Saving properties");
         $this->properties->save();
         $this->katana->console->system("Closing console");
         $this->console->kill();
         $this->katana->console->system("Stopping network interfaces");
         foreach ($this->network->getInterfaces() as $interface) {
             $interface->shutdown();
             $this->network->unregisterInterface($interface);
         }
         $this->memoryManager->doObjectCleanup();
         gc_collect_cycles();
     } catch (\Exception $e) {
         $this->logger->emergency("Crashed while crashing, killing process");
         @kill(getmypid());
     }
 }
Ejemplo n.º 2
0
 public function forceShutdown()
 {
     if ($this->hasStopped) {
         return;
     }
     try {
         if (!$this->isRunning()) {
             $this->sendUsage(SendUsageTask::TYPE_CLOSE);
         }
         $this->hasStopped = true;
         $this->shutdown();
         if ($this->rcon instanceof RCON) {
             $this->rcon->stop();
         }
         if ($this->getProperty("network.upnp-forwarding", false) === true) {
             $this->logger->info("[UPnP] Removing port forward...");
             UPnP::RemovePortForward($this->getPort());
         }
         $this->getLogger()->debug("Disabling all plugins");
         $this->pluginManager->disablePlugins();
         foreach ($this->players as $player) {
             $player->close($player->getLeaveMessage(), $this->getProperty("settings.shutdown-message", "Server closed"));
         }
         $this->getLogger()->debug("Unloading all levels");
         foreach ($this->getLevels() as $level) {
             $this->unloadLevel($level, true);
         }
         $this->getLogger()->debug("Removing event handlers");
         HandlerList::unregisterAll();
         $this->getLogger()->debug("Stopping all tasks");
         $this->scheduler->cancelAllTasks();
         $this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
         $this->getLogger()->debug("Saving properties");
         $this->properties->save();
         $this->getLogger()->debug("Closing console");
         $this->console->kill();
         $this->getLogger()->debug("Stopping network interfaces");
         foreach ($this->network->getInterfaces() as $interface) {
             $interface->shutdown();
             $this->network->unregisterInterface($interface);
         }
         $this->memoryManager->doObjectCleanup();
         gc_collect_cycles();
     } catch (\Exception $e) {
         $this->logger->emergency("Crashed while crashing, killing process");
         @kill(getmypid());
     }
 }
Ejemplo n.º 3
0
 public function reload()
 {
     $this->logger->info("Saving levels...");
     foreach ($this->levels as $level) {
         $level->save();
     }
     $this->pluginManager->disablePlugins();
     $this->pluginManager->clearPlugins();
     $this->commandMap->clearCommands();
     $this->logger->info("Reloading properties...");
     $this->properties->reload();
     $this->advancedConfig->reload();
     $this->loadAdvancedConfig();
     $this->maxPlayers = $this->getConfigInt("max-players", 20);
     if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
         $this->setConfigInt("difficulty", 3);
     }
     $this->banByIP->load();
     $this->banByName->load();
     $this->banByCID->load();
     $this->reloadWhitelist();
     $this->operators->reload();
     $this->memoryManager->doObjectCleanup();
     foreach ($this->getIPBans()->getEntries() as $entry) {
         $this->getNetwork()->blockAddress($entry->getName(), -1);
     }
     $this->pluginManager->registerInterface(PharPluginLoader::class);
     $this->pluginManager->registerInterface(FolderPluginLoader::class);
     $this->pluginManager->registerInterface(ScriptPluginLoader::class);
     $this->pluginManager->loadPlugins($this->pluginPath);
     $this->enablePlugins(PluginLoadOrder::STARTUP);
     $this->enablePlugins(PluginLoadOrder::POSTWORLD);
     TimingsHandler::reload();
 }