isValid() public method

Checks if this object has a valid reference to a Level
public isValid ( ) : boolean
return boolean
Beispiel #1
1
 public function teleport(Player $player)
 {
     if ($this->message !== null) {
         $player->sendMessage($this->message);
     }
     if ($this->position instanceof Position) {
         if ($this->position->isValid()) {
             if ($this->position instanceof WeakPosition) {
                 $this->position->updateProperties();
             }
             //Server::getInstance()->getLogger()->info($this->position->x . " : " . $this->position->y . " : " . $this->position->z);
             $player->teleport($this->position);
         } else {
             $player->sendMessage($this->getApi()->executeTranslationItem("level-not-loaded-warp"));
         }
     } else {
         $plugin = $player->getServer()->getPluginManager()->getPlugin("FastTransfer");
         if ($plugin instanceof PluginBase && $plugin->isEnabled() && $plugin instanceof FastTransfer) {
             $plugin->transferPlayer($player, $this->address, $this->port);
         } else {
             $player->getServer()->getPluginManager()->getPlugin("SimpleWarp")->getLogger()->warning("In order to use warps tp other servers, you must install " . TextFormat::AQUA . "FastTransfer" . TextFormat::RESET . ".");
             $player->sendPopup(TextFormat::RED . "Warp failed!" . TextFormat::RESET);
         }
     }
 }
 public function putPosition(Position $position)
 {
     $this->putLong($position->x);
     $this->putShort($position->y);
     $this->putLong($position->z);
     $this->putString($position->isValid() ? $position->getLevel()->getName() : "");
 }
Beispiel #3
0
 /**
  * @return bool
  */
 public function hasValidSpawnPosition() : bool
 {
     return $this->spawnPosition instanceof WeakPosition and $this->spawnPosition->isValid();
 }