本文整理汇总了PHP中pocketmine\level\Level::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Level::getName方法的具体用法?PHP Level::getName怎么用?PHP Level::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\level\Level
的用法示例。
在下文中一共展示了Level::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getShield
/**
* @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;
}
示例2: getWorldLoadedData
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();
}
示例3: getWorldLoadedData
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();
}
示例4: setMetadata
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());
}
}
示例5: isRegistered
public static function isRegistered(Level $level)
{
if (isset(self::$registeredLevel[$level->getName()])) {
return true;
}
return false;
}
示例6: isLevelCorrect
public function isLevelCorrect(Level $level)
{
if ($this->world === "*") {
return true;
}
return strtolower($level->getName()) === $this->world;
}
示例7: delHome
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();
}
示例8: loadInventory
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;
}
示例9: loadCfg
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]];
}
}
示例10: isActiveIn
public function isActiveIn(Level $level)
{
if ($this->activeIn === false) {
return true;
} else {
return in_array($level->getName(), $this->activeIn);
}
}
示例11: switchLevelVanish
/**
* 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);
}
}
}
}
}
}
示例12: sendLevelInfo
/**
* @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"));
}
示例13: teleportToSpawn_2
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;
}
示例14: createForWrite
/**
* 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;
}
示例15: claimingIsDisabled
public function claimingIsDisabled(Level $level)
{
$disabledWorlds = explode(":", file_get_contents($this->getDataFolder() . "NoClaimWorlds.txt"));
return in_array($level->getName(), $disabledWorlds);
}