当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::setExpLevel方法代码示例

本文整理汇总了PHP中pocketmine\Player::setExpLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::setExpLevel方法的具体用法?PHP Player::setExpLevel怎么用?PHP Player::setExpLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::setExpLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: TeleportToTeamSpawn

 public function TeleportToTeamSpawn(Player $p, $team, $arena)
 {
     $p->setHealth(20);
     $p->setFood(20);
     $p->setGamemode(0);
     $p->getInventory()->clearAll();
     $p->setExpLevel(0);
     $config = new Config($this->getDataFolder() . "Arenas/" . $arena . ".yml", Config::YAML);
     $welt = $config->getNested("Spawn." . $team . ".Welt");
     $x = $config->getNested("Spawn." . $team . ".X");
     $y = $config->getNested("Spawn." . $team . ".Y");
     $z = $config->getNested("Spawn." . $team . ".Z");
     $yaw = $config->getNested("Spawn." . $team . ".Yaw");
     $pitch = $config->getNested("Spawn." . $team . ".Pitch");
     if ($p->getLevel() != $this->getServer()->getLevelByName($welt)) {
         $p->teleport($this->getServer()->getLevelByName($welt)->getSafeSpawn(), 0, 0);
     }
     $p->teleport(new Vector3($x, $y, $z), $yaw, $pitch);
 }
开发者ID:Bluplayz,项目名称:BedwarsPE,代码行数:19,代码来源:Bedwars.php

示例2: onRename

 public function onRename(Item $item, Player $player) : bool
 {
     if ($player->getExpLevel() > $item->getRepairCost()) {
         $player->setExpLevel($player->getExpLevel() - $item->getRepairCost());
         return true;
     }
     return false;
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:8,代码来源:AnvilInventory.php

示例3: onRename

 public function onRename(Player $player, Item $resultItem) : bool
 {
     if (!$resultItem->deepEquals($this->getItem(self::TARGET), true, false, true)) {
         //Item does not match target item. Everything must match except the tags.
         return false;
     }
     if ($player->getExpLevel() < $resultItem->getRepairCost()) {
         //Not enough exp
         return false;
     }
     $player->setExpLevel($player->getExpLevel() - $resultItem->getRepairCost());
     $this->clearAll();
     if (!$player->getServer()->allowInventoryCheats and !$player->isCreative()) {
         if (!$player->getFloatingInventory()->canAddItem($resultItem)) {
             return false;
         }
         $player->getFloatingInventory()->addItem($resultItem);
     }
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:20,代码来源:AnvilInventory.php

示例4: onEnchant

 public function onEnchant(Player $who, Item $before, Item $after)
 {
     $result = $before->getId() == Item::BOOK ? new EnchantedBook() : $before;
     if (!$before->hasEnchantments() and $after->hasEnchantments() and $after->getId() == $result->getId() and $this->levels != null and $this->entries != null) {
         $enchantments = $after->getEnchantments();
         for ($i = 0; $i < 3; $i++) {
             if ($this->checkEnts($enchantments, $this->entries[$i]->getEnchantments())) {
                 $lapis = $this->getItem(1);
                 $level = $who->getExpLevel();
                 $cost = $this->entries[$i]->getCost();
                 if ($lapis->getId() == Item::DYE and $lapis->getDamage() == Dye::BLUE and $lapis->getCount() > $i and $level >= $cost) {
                     foreach ($enchantments as $enchantment) {
                         $result->addEnchantment($enchantment);
                     }
                     $this->setItem(0, $result);
                     $lapis->setCount($lapis->getCount() - $i - 1);
                     $this->setItem(1, $lapis);
                     $who->setExpLevel($level - $i - 1);
                     break;
                 }
             }
         }
     }
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:24,代码来源:EnchantInventory.php


注:本文中的pocketmine\Player::setExpLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。