setDefaultLevel() public method

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
ファイル: Level.php プロジェクト: robozeri/Yuriko-MP
 /**
  * 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
ファイル: Level.php プロジェクト: RedstoneAlmeida/Steadfast2
 /**
  * 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
ファイル: Level.php プロジェクト: AbelGamerC/Katana
 /**
  * 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;
 }