getLanguage() public method

public getLanguage ( ) : BaseLang
return pocketmine\lang\BaseLang
示例#1
0
 /**
  * @return void
  */
 public function registerServerAliases()
 {
     $values = $this->server->getCommandAliases();
     foreach ($values as $alias => $commandStrings) {
         if (strpos($alias, ":") !== false or strpos($alias, " ") !== false) {
             $this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.illegal", [$alias]));
             continue;
         }
         $targets = [];
         $bad = "";
         foreach ($commandStrings as $commandString) {
             $args = explode(" ", $commandString);
             $command = $this->getCommand($args[0]);
             if ($command === null) {
                 if (strlen($bad) > 0) {
                     $bad .= ", ";
                 }
                 $bad .= $commandString;
             } else {
                 $targets[] = $commandString;
             }
         }
         if (strlen($bad) > 0) {
             $this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.notFound", [$alias, $bad]));
             continue;
         }
         //These registered commands have absolute priority
         if (count($targets) > 0) {
             $this->knownCommands[strtolower($alias)] = new FormattedCommandAlias(strtolower($alias), $targets);
         } else {
             unset($this->knownCommands[strtolower($alias)]);
         }
     }
 }
 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
         $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()]));
         $this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
         $plugin->setEnabled(false);
     }
 }
示例#3
0
 public function processInterfaces()
 {
     foreach ($this->interfaces as $interface) {
         try {
             $interface->process();
         } catch (\Throwable $e) {
             $logger = $this->server->getLogger();
             if (\pocketmine\DEBUG > 1) {
                 if ($logger instanceof MainLogger) {
                     $logger->logException($e);
                 }
             }
             $interface->emergencyShutdown();
             $this->unregisterInterface($interface);
             $logger->critical($this->server->getLanguage()->translateString("pocketmine.server.networkError", [get_class($interface), $e->getMessage()]));
         }
     }
 }
 /**
  * Registers all the events in the given Listener class
  *
  * @param Listener $listener
  * @param Plugin   $plugin
  *
  * @throws PluginException
  */
 public function registerEvents(Listener $listener, Plugin $plugin)
 {
     if (!$plugin->isEnabled()) {
         throw new PluginException("Plugin attempted to register " . get_class($listener) . " while not enabled");
     }
     $reflection = new \ReflectionClass(get_class($listener));
     foreach ($reflection->getMethods() as $method) {
         if (!$method->isStatic()) {
             $priority = EventPriority::NORMAL;
             $ignoreCancelled = false;
             if (preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
                 $matches[1] = strtoupper($matches[1]);
                 if (defined(EventPriority::class . "::" . $matches[1])) {
                     $priority = constant(EventPriority::class . "::" . $matches[1]);
                 }
             }
             if (preg_match("/^[\t ]*\\* @ignoreCancelled[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
                 $matches[1] = strtolower($matches[1]);
                 if ($matches[1] === "false") {
                     $ignoreCancelled = false;
                 } elseif ($matches[1] === "true") {
                     $ignoreCancelled = true;
                 }
             }
             $parameters = $method->getParameters();
             if (count($parameters) === 1 and $parameters[0]->getClass() instanceof \ReflectionClass and is_subclass_of($parameters[0]->getClass()->getName(), Event::class)) {
                 $class = $parameters[0]->getClass()->getName();
                 $reflection = new \ReflectionClass($class);
                 if (strpos((string) $reflection->getDocComment(), "@deprecated") !== false and $this->server->getProperty("settings.deprecated-verbose", true)) {
                     $this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.plugin.deprecatedEvent", [$plugin->getName(), $class, get_class($listener) . "->" . $method->getName() . "()"]));
                 }
                 $this->registerEvent($class, $listener, $priority, new MethodEventExecutor($method->getName()), $plugin, $ignoreCancelled);
             }
         }
     }
 }
示例#5
0
 public function unloadChunk($x, $z, $safe = true, $trySave = true)
 {
     if ($safe === true and $this->isChunkInUse($x, $z)) {
         return false;
     }
     if (!$this->isChunkLoaded($x, $z)) {
         return true;
     }
     $this->timings->doChunkUnload->startTiming();
     $index = Level::chunkHash($x, $z);
     $chunk = $this->getChunk($x, $z);
     if ($chunk !== null and $chunk->getProvider() !== null) {
         $this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($chunk));
         if ($ev->isCancelled()) {
             $this->timings->doChunkUnload->stopTiming();
             return false;
         }
     }
     try {
         if ($chunk !== null) {
             if ($trySave and $this->getAutoSave()) {
                 $entities = 0;
                 foreach ($chunk->getEntities() as $e) {
                     if ($e instanceof Player) {
                         continue;
                     }
                     ++$entities;
                 }
                 if ($chunk->hasChanged() or count($chunk->getTiles()) > 0 or $entities > 0) {
                     $this->provider->setChunk($x, $z, $chunk);
                     $this->provider->saveChunk($x, $z);
                 }
             }
             foreach ($this->getChunkLoaders($x, $z) as $loader) {
                 $loader->onChunkUnloaded($chunk);
             }
         }
         $this->provider->unloadChunk($x, $z, $safe);
     } catch (\Exception $e) {
         $logger = $this->server->getLogger();
         $logger->error($this->server->getLanguage()->translateString("pocketmine.level.chunkUnloadError", [$e->getMessage()]));
         if ($logger instanceof MainLogger) {
             $logger->logException($e);
         }
     }
     unset($this->chunks[$index]);
     unset($this->chunkTickList[$index]);
     unset($this->chunkCache[$index]);
     $this->timings->doChunkUnload->stopTiming();
     return true;
 }