getName() public method

Returns the Level name
public getName ( ) : string
return string
 /**
  * @param Level $level
  * @return Shield|null
  */
 public function getShield(Level $level)
 {
     if (isset($this->shields[strtolower($level->getName())])) {
         return $this->shields[strtolower($level->getName())];
     }
     return null;
 }
Esempio n. 2
0
 public function getWorldLoadedData(Level $level)
 {
     $temp_config = $this->getUserData();
     if (!isset($temp_config["worlds"][$level->getName()])) {
         $temp_config["worlds"][$level->getName()] = array("group" => $this->plugin->getDefaultGroup()->getName(), "permissions" => array());
         $this->setUserData($temp_config);
     }
     return $this->getUserData();
 }
Esempio n. 3
0
 public function getWorldLoadedData(Level $level)
 {
     $temp_config = $this->plugin->getGroupsData();
     if (!isset($temp_config[$this->groupName]["worlds"][$level->getName()])) {
         $this->plugin->getLogger()->warning("Permissions not set in " . $this->groupName . " in level: " . $level->getName() . ".");
         $temp_config[$this->groupName]["worlds"][$level->getName()] = array("permissions" => array());
         $this->plugin->setGroupsData($temp_config);
     }
     return $this->plugin->getGroupsData();
 }
Esempio n. 4
0
 public function setMetadata($block, $metadataKey, MetadataValue $newMetadatavalue)
 {
     if (!$block instanceof Block) {
         throw new \InvalidArgumentException("Object must be a Block");
     }
     if ($block->getLevel() === $this->owningLevel) {
         parent::setMetadata($block, $metadataKey, $newMetadatavalue);
     } else {
         throw new \InvalidStateException("Block does not belong to world " . $this->owningLevel->getName());
     }
 }
Esempio n. 5
0
 public static function isRegistered(Level $level)
 {
     if (isset(self::$registeredLevel[$level->getName()])) {
         return true;
     }
     return false;
 }
Esempio n. 6
0
 public function isLevelCorrect(Level $level)
 {
     if ($this->world === "*") {
         return true;
     }
     return strtolower($level->getName()) === $this->world;
 }
 public function delHome(IPlayer $player, Level $level)
 {
     $n = strtolower($player->getName());
     $l = "l-" . strtolower($level->getName());
     if (!isset($this->homes[$l]) || !isset($this->homes[$l][$n])) {
         return;
     }
     unset($this->homes[$l][$n]);
     if (count($this->homes[$l]) == 0) {
         unset($this->homes[$l]);
     }
     $this->saveHomes();
 }
Esempio n. 8
0
 private function loadInventory(Player $player, Level $level)
 {
     $n = trim(strtolower($player->getName()));
     if ($n === "") {
         return false;
     }
     $d = substr($n, 0, 1);
     $path = $this->getDataFolder() . $d . "/" . $n . ".yml";
     if (!is_file($path)) {
         return false;
     }
     $cfg = new Config($path, Config::YAML);
     $yaml = $cfg->getAll();
     $ln = trim(strtolower($level->getName()));
     if (!isset($yaml[$ln])) {
         return false;
     }
     foreach ($yaml[$ln] as $slot => $t) {
         list($id, $dam, $cnt) = explode(":", $t);
         $item = Item::get($id, $dam, $cnt);
         $player->getInventory()->setItem($slot, $item);
     }
     return true;
 }
Esempio n. 9
0
 private function loadCfg(Level $lv)
 {
     $world = $lv->getName();
     $f = $lv->getProvider()->getPath() . "itemcasepe.txt";
     $this->cases[$world] = [];
     if (!file_exists($f)) {
         return;
     }
     foreach (explode("\n", file_get_contents($f)) as $ln) {
         if (preg_match('/^\\s*#/', $ln)) {
             continue;
         }
         if (($ln = trim($ln)) == "") {
             continue;
         }
         $v = explode(",", $ln);
         if (count($v) < 3) {
             continue;
         }
         $this->cases[$world][$v[0]] = ["item" => $v[1], "count" => $v[2]];
     }
 }
Esempio n. 10
0
 public function isActiveIn(Level $level)
 {
     if ($this->activeIn === false) {
         return true;
     } else {
         return in_array($level->getName(), $this->activeIn);
     }
 }
Esempio n. 11
0
 /**
  * Allow to switch between levels Vanished!
  * You need to teleport the player to a different level in order to call this event
  *
  * @param Player $player
  * @param Level $origin
  * @param Level $target
  */
 public function switchLevelVanish(Player $player, Level $origin, Level $target)
 {
     if ($origin->getName() !== $target->getName() && $this->isVanished($player)) {
         // This will be used if the specified player has "noPacket" enabled.
         // A temporal check will be used for "the other players".
         $noPacket = $this->hasNoPacket($player);
         // Just as prevention if any player has "noPacket" disabled...
         $pk = new MobEffectPacket();
         $pk->effectId = $this->invisibilityEffect->getId();
         $pk->amplifier = $this->invisibilityEffect->getAmplifier();
         $pk->particles = $this->invisibilityEffect->isVisible();
         $pk->duration = $this->invisibilityEffect->getDuration();
         // Show to origin's players
         $pk->eventId = MobEffectPacket::EVENT_REMOVE;
         foreach ($origin->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->showPlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->showPlayer($p);
                     }
                 }
             }
         }
         // Hide to target's players
         $pk->eventId = MobEffectPacket::EVENT_ADD;
         foreach ($target->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->hidePlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->hidePlayer($p);
                     }
                 }
             }
         }
     }
 }
 /**
  * @param CommandSender $sender
  * @param Level $level
  */
 public function sendLevelInfo(CommandSender $sender, Level $level)
 {
     $sender->sendMessage("Name: " . $level->getName());
     $sender->sendMessage("Id: " . $level->getId());
     $sender->sendMessage("Entities: " . count($level->getEntities()));
     $sender->sendMessage("Players: " . count($level->getPlayers()));
     $sender->sendMessage("Tiles: " . count($level->getTiles()));
     $sender->sendMessage("Chunks: " . count($level->getChunks()));
     $sender->sendMessage("Loaders: " . count($level->getLoaders()));
     $sender->sendMessage("Spawn: " . $level->getSafeSpawn()->getFloorX() . ":" . $level->getSafeSpawn()->getFloorY() . ":" . $level->getSafeSpawn()->getFloorZ());
     $sender->sendMessage("Time: " . $level->getTime());
     $sender->sendMessage("Tick-rate: " . $level->getTickRate());
     $sender->sendMessage("Tick-rate-time: " . $level->getTickRateTime());
     $sender->sendMessage("Seed: " . $level->getSeed());
     $sender->sendMessage("Is-auto-saving: " . ($level->getAutoSave() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-generated: " . ($level->getServer()->isLevelGenerated($level->getName()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-loaded: " . ($level->getServer()->isLevelLoaded($level->getName()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
 }
Esempio n. 13
0
 public function teleportToSpawn_2(Player $player, Level $level)
 {
     $temp = $this->getConfig()->getAll();
     $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
     $spawns = $spawns->getAll();
     if (isset($spawns[$level->getName()])) {
         $player->teleport(new Position($spawns[$level->getName()]["X"], $spawns[$level->getName()]["Y"], $spawns[$level->getName()]["Z"]), $spawns[$level->getName()]["Yaw"], $spawns[$level->getName()]["Pitch"]);
         if ($temp["enable-spawn-message"] == true) {
             $player->sendMessage($this->translateColors("&", $this->getSpawnMessage_2($player, $level)));
         }
     } else {
         $player->sendMessage($this->translateColors("&", $this->getNoSpawnMessage()));
     }
     return true;
 }
Esempio n. 14
0
 /**
  * Creates a new clip for writing
  *
  * @param Level   $level
  * @param Vector3 $anchor
  * @param string  $owner
  * @param string  $name
  *
  * @return Clip
  */
 public static function createForWrite(Level $level, Vector3 $anchor, $owner, $name = "default")
 {
     $clip = new Clip($name, true);
     $clip->levelName = $level->getName();
     $clip->anchor = new Vector3($anchor->x, $anchor->y, $anchor->z);
     // prevent memory leak
     $clip->creationTime = time();
     $clip->owner = $owner;
     return $clip;
 }
Esempio n. 15
0
 public function claimingIsDisabled(Level $level)
 {
     $disabledWorlds = explode(":", file_get_contents($this->getDataFolder() . "NoClaimWorlds.txt"));
     return in_array($level->getName(), $disabledWorlds);
 }
Esempio n. 16
0
 public function resetLevel(Level $level)
 {
     $levelname = $level->getName();
     if ($this->getServer()->isLevelLoaded($levelname)) {
         $this->getServer()->unloadLevel($level, true);
     }
     $this->copyr($this->getDataFolder() . "/worlds/" . $levelname, $this->getServer()->getDataPath() . "/worlds/" . $levelname);
     if (!$this->getServer()->isLevelLoaded($levelname)) {
         $this->getServer()->loadLevel($levelname);
     }
     $this->copyr($this->getServer()->getDataPath() . "/worlds/" . $levelname, $this->getDataFolder() . "/worlds/" . $levelname);
 }
 /**
  * @param Item $item
  * @param Level $level
  * @return bool
  */
 public function isItemBannedInLevel(Item $item, Level $level)
 {
     return in_array($item->getId() . ":" . $item->getDamage(), $this->getConfig()->getNested("level." . strtolower($level->getName()) . ".bannedItems"));
 }
Esempio n. 18
0
 /**
  * Get default quit message
  *
  * @param Player $player
  * @param Level $origin
  * @param Level $target
  *
  * @return string The default world change message
  */
 public function getDefaultWorldChangeMessage(Player $player, Level $origin, Level $target)
 {
     $cfg = $this->getConfig()->getAll();
     $message = $cfg["WorldChange"]["message"];
     $message = str_replace("{ORIGIN}", $origin->getName(), $message);
     $message = str_replace("{TARGET}", $target->getName(), $message);
     $message = str_replace("{PLAYER}", $player->getName(), $message);
     $message = str_replace("{MAXPLAYERS}", $this->getServer()->getMaxPlayers(), $message);
     $message = str_replace("{TOTALPLAYERS}", count($this->getServer()->getOnlinePlayers()), $message);
     $message = str_replace("{TIME}", date($cfg["datetime-format"]), $message);
     return $this->translateColors("&", $message);
 }
Esempio n. 19
0
 /**
  *
  * @param string $jail        	
  * @param int $x        	
  * @param int $y        	
  * @param int $z        	
  * @param Level $world        	
  * @return boolean
  */
 public function setJail($jail, $x, $y, $z, $world)
 {
     $this->getServer()->getPluginManager()->callEvent($event = new SetjailEvent($this, $jail, new Position($x, $y, $z, $world)));
     if ($event->isCancelled()) {
         return false;
     }
     $j = $this->data2->getAll();
     if (isset($j[$jail])) {
         return false;
     }
     $j[$jail]["x"] = $x;
     $j[$jail]["y"] = $y;
     $j[$jail]["z"] = $z;
     $j[$jail]["world"] = $world->getName();
     $this->data2->setAll($j);
     $this->data2->save();
     return true;
 }
Esempio n. 20
0
 public function getDb(Level $level)
 {
     return isset($this->dbs[$name = $level->getName()]) ? $this->dbs[$name] : false;
 }