setDefaultLevel() публичный Метод

Sets the default level to a different level This won't change the level-name property, it only affects the server on runtime
public setDefaultLevel ( Level $level )
$level pocketmine\level\Level
Пример #1
0
 /**
  * Unloads the current level from memory safely
  *
  * @param bool $force default false, force unload of default level
  *
  * @return bool
  */
 public function unload($force = false)
 {
     $ev = new LevelUnloadEvent($this);
     if ($this === $this->server->getDefaultLevel() and $force !== true) {
         $ev->setCancelled(true);
     }
     $this->server->getPluginManager()->callEvent($ev);
     if (!$force and $ev->isCancelled()) {
         return false;
     }
     $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.unloading", [$this->getName()]));
     $defaultLevel = $this->server->getDefaultLevel();
     foreach ($this->getPlayers() as $player) {
         if ($this === $defaultLevel or $defaultLevel === null) {
             $player->close($player->getLeaveMessage(), "Forced default level unload");
         } elseif ($defaultLevel instanceof Level) {
             $player->teleport($this->server->getDefaultLevel()->getSafeSpawn());
         }
     }
     if ($this === $defaultLevel) {
         $this->server->setDefaultLevel(null);
     }
     $this->close();
     return true;
 }
Пример #2
0
 /**
  * Unloads the current level from memory safely
  *
  * @param bool $force default false, force unload of default level
  *
  * @return bool
  */
 public function unload($force = false)
 {
     $ev = new LevelUnloadEvent($this);
     if ($this === $this->server->getDefaultLevel() and $force !== true) {
         $ev->setCancelled(true);
     }
     $this->server->getPluginManager()->callEvent($ev);
     if (!$force and $ev->isCancelled()) {
         return false;
     }
     $this->server->getLogger()->info("Unloading level \"" . $this->getName() . "\"");
     $defaultLevel = $this->server->getDefaultLevel();
     foreach ($this->getPlayers() as $player) {
         if ($this === $defaultLevel or $defaultLevel === null) {
             $player->close(TextFormat::YELLOW . $player->getName() . " has left the game", "Forced default level unload");
         } elseif ($defaultLevel instanceof Level) {
             $player->teleport($this->server->getDefaultLevel()->getSafeSpawn());
         }
     }
     if ($this === $defaultLevel) {
         $this->server->setDefaultLevel(null);
     }
     $this->close();
     return true;
 }
Пример #3
0
 /**
  * Unloads the current level from memory safely
  *
  * @param bool $force default false, force unload of default level
  *
  * @return bool
  */
 public function unload($force = false)
 {
     $ev = new LevelUnloadEvent($this);
     if ($this === $this->server->getDefaultLevel() and $force !== true) {
         $ev->setCancelled(true);
     }
     $this->server->getPluginManager()->callEvent($ev);
     if (!$force and $ev->isCancelled()) {
         return false;
     }
     $this->server->getKatana()->console->system("Unloading level " . Terminal::$COLOR_WHITE . $this->getName());
     $defaultLevel = $this->server->getDefaultLevel();
     foreach ($this->getPlayers() as $player) {
         if ($this === $defaultLevel or $defaultLevel === null) {
             $player->close($player->getLeaveMessage(), "Forced default level unload");
         } elseif ($defaultLevel instanceof Level) {
             $player->teleport($this->server->getDefaultLevel()->getSafeSpawn());
         }
     }
     if ($this === $defaultLevel) {
         $this->server->setDefaultLevel(null);
     }
     $this->close();
     return true;
 }