Inheritance: implements pocketmine\command\CommandMap
Exemplo n.º 1
0
 /**
  * @param string         $path
  * @param PluginLoader[] $loaders
  *
  * @return Plugin
  */
 public function loadPlugin($path, $loaders = null)
 {
     foreach ($loaders === null ? $this->fileAssociations : $loaders as $loader) {
         if (preg_match($loader->getPluginFilters(), basename($path)) > 0) {
             $description = $loader->getPluginDescription($path);
             if ($description instanceof PluginDescription) {
                 if (($plugin = $loader->loadPlugin($path)) instanceof Plugin) {
                     $this->plugins[$plugin->getDescription()->getName()] = $plugin;
                     $pluginCommands = $this->parseYamlCommands($plugin);
                     if (count($pluginCommands) > 0) {
                         $this->commandMap->registerAll($plugin->getDescription()->getName(), $pluginCommands);
                     }
                     return $plugin;
                 }
             }
         }
     }
     return null;
 }
Exemplo n.º 2
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->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->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(ScriptPluginLoader::class);
     $this->pluginManager->loadPlugins($this->pluginPath);
     $this->enablePlugins(PluginLoadOrder::STARTUP);
     $this->enablePlugins(PluginLoadOrder::POSTWORLD);
     TimingsHandler::reload();
 }
Exemplo 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->maxPlayers = $this->getConfigInt("max-players", 20);
     if (($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", "256M")))) !== false) {
         $value = ["M" => 1, "G" => 1024];
         $real = (int) substr($memory, 0, -1) * $value[substr($memory, -1)];
         if ($real < 256) {
             $this->logger->warning($this->getName() . " may not work right with less than 256MB of RAM", true, true, 0);
         }
         @ini_set("memory_limit", $memory);
     } else {
         $this->setConfigString("memory-limit", "256M");
     }
     if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
         $this->setConfigInt("difficulty", 3);
     }
     $this->banByIP->load();
     $this->banByName->load();
     $this->reloadWhitelist();
     $this->operators->reload();
     foreach ($this->getIPBans()->getEntries() as $entry) {
         $this->blockAddress($entry->getName(), -1);
     }
     $this->pluginManager->registerInterface(PharPluginLoader::class);
     $this->pluginManager->loadPlugins($this->pluginPath);
     $this->enablePlugins(PluginLoadOrder::STARTUP);
     $this->enablePlugins(PluginLoadOrder::POSTWORLD);
     TimingsHandler::reload();
 }