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


PHP Player::add方法代码示例

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


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

示例1: onShootRun

 public function onShootRun(array $args, Player $player)
 {
     if (!isset($args[0]) or !is_numeric($args[0])) {
         return self::WRONG_USE;
     }
     $length = floatval(array_shift($args));
     $p1 = $player->getPosition()->floor();
     $p2 = $player->add($player->getDirectionVector()->multiply($length))->floor();
     if ($p1->y < 0 or $p1->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "You must be inside the building height!";
     } elseif ($p2->y < 0 or $p2->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "The selected area exceeded the world height limit!";
     }
     $player->getLevel()->loadChunk($p2->x >> 4, $p2->z >> 4);
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "adverse":
                 $cache = [$p1, $p2];
                 $p1 = $cache[1];
                 $p2 = $cache[0];
                 break;
         }
     }
     $level = $player->getLevel();
     $this->getMain()->setSelection($player, $sel = new CuboidSpace($p1 = Position::fromObject($p1, $level), $p2 = Position::fromObject($p2, $level)));
     return "Cuboid selection set: {$sel} (" . count($sel->getPosList()) . " blocks)";
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:29,代码来源:Cuboid.php

示例2: launch

 public function launch(Player $player)
 {
     $dir = $player->getDirectionVector();
     $frontPos = $player->add($dir->multiply(1.1));
     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $frontPos->x), new Double("", $frontPos->y + $player->getEyeHeight()), new Double("", $frontPos->z)]), "Motion" => new Enum("Motion", [new Double("", $dir->x), new Double("", $dir->y), new Double("", $dir->z)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]);
     $f = $this->f;
     $launched = Entity::createEntity($this->getEntityName(), $player->chunk, $nbt);
     $launched->setMotion($launched->getMotion()->multiply($f));
     if ($launched instanceof Projectile) {
         $player->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($launched));
         if ($projectileEv->isCancelled()) {
             $launched->kill();
         } else {
             $launched->spawnToAll();
             $player->level->addSound(new LaunchSound($player), $player->getViewers());
         }
     } else {
         $launched->spawnToAll();
     }
 }
开发者ID:kiyoshi-kurosaki,项目名称:ClearSky,代码行数:20,代码来源:Launchable.php

示例3: nuke

 /**
  * Spawn a carpet of bomb!
  *
  * @param Player $player
  */
 public function nuke(Player $player)
 {
     for ($x = -10; $x <= 10; $x += 5) {
         for ($z = -10; $z <= 10; $z += 5) {
             $this->createTNT($player->add($x, 0, $z), $player->getLevel());
         }
     }
 }
开发者ID:mwvent,项目名称:WattzEssentialsPE,代码行数:13,代码来源:Loader.php

示例4: particleToPotato

 public function particleToPotato()
 {
     $this->potato->getLevel()->addParticle(new FloatingTextParticle($this->potato->add(0.1 * mt_rand(1, 9) * mt_rand(-1, 1), 0.1 * mt_rand(5, 9), 0.1 * mt_rand(1, 9) * mt_rand(-1, 1)), TextFormat::RED . $this->time));
     $this->potato->getLevel()->addParticle(new DustParticle($this->potato->add(mt_rand(-3, 3), mt_rand(-3, 3), mt_rand(-3, 3)), 211, 161, 80, 255));
 }
开发者ID:ChalkPE,项目名称:HotPotato,代码行数:5,代码来源:HotPotato.php

示例5: particle

 public function particle(Player $player)
 {
     $pos = $player->add(0, 2, 0);
     $player->getLevel()->addParticle(new DustParticle($pos->setComponents($pos->x + 0.4, $pos->y, $pos->z), 188, 32, 255, 255));
     $player->getLevel()->addParticle(new DustParticle($pos->setComponents($pos->x, $pos->y, $pos->z + 0.4), 188, 32, 255, 255));
     $player->getLevel()->addParticle(new DustParticle($pos->setComponents($pos->x - 0.6, $pos->y, $pos->z), 188, 32, 255, 255));
     $player->getLevel()->addParticle(new DustParticle($pos->setComponents($pos->x, $pos->y, $pos->z - 0.6), 188, 32, 255, 255));
     $player->getLevel()->addParticle(new DustParticle($pos->setComponents($pos->x + 0.4, $pos->y, $pos->z + 0.4), 188, 32, 255, 255));
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:9,代码来源:Trampoline.php

示例6: NydusCanal

 public function NydusCanal(Player $player, $warp = null)
 {
     if ($warp == null) {
         return false;
     }
     if (isset(explode("[", $warp)[1])) {
         $level = explode("[", $warp)[1];
         $level = explode("]", $level)[0];
         $level = $this->getServer()->getLevelByName($level);
         if (!$level instanceof Level) {
             $player->sendMessage(TextFormat::DARK_AQUA . $level . "맵 폴더를 찾을 수 없습니다 !, 워프불가");
             return false;
         }
         $pos = $level->getSafeSpawn();
         if ($pos == false) {
             $player->sendMessage(TextFormat::RED . "해당 맵의 기본스폰위치를 찾을 수없습니다, 워프불가");
             return false;
         }
         $player->teleport($pos);
         return true;
     }
     if (!isset($this->NydusCanal_List["warp"][$warp])) {
         $player->sendMessage(TextFormat::DARK_AQUA . "해당 워프가 삭제되어있습니다 !, 워프불가");
         return false;
     }
     $x = $this->NydusCanal_List["warp"][$warp]['x'];
     $y = $this->NydusCanal_List["warp"][$warp]['y'];
     $z = $this->NydusCanal_List["warp"][$warp]['z'];
     $yaw = $this->NydusCanal_List["warp"][$warp]['yaw'];
     $pitch = $this->NydusCanal_List["warp"][$warp]['pitch'];
     $level = $this->getServer()->getLevelByName($this->NydusCanal_List["warp"][$warp]['level']);
     if (!$level instanceof Level) {
         $player->sendMessage(TextFormat::DARK_AQUA . $this->NydusCanal_List["warp"][$warp]['level'] . "맵 폴더를 찾을 수 없습니다 !, 워프불가");
         return false;
     }
     if (!$player->hasPermission("nyduscanal.lockwarp")) {
         if (isset($this->NydusCanal_List["locked"][$warp])) {
             $player->sendMessage(TextFormat::DARK_AQUA . "해당 워프가 잠겨있습니다, 워프불가");
             return false;
         }
     }
     if (isset($this->NydusCanal_List["warp"][$warp]["cooltime"])) {
         if (!isset($this->customCooltime[$warp][$player->getName()])) {
             $this->customCooltime[$warp][$player->getName()] = date("Y-m-d H:i:s");
         } else {
             $before = $this->makeTimestamp($this->customCooltime[$warp][$player->getName()]);
             $after = $this->makeTimestamp(date("Y-m-d H:i:s"));
             $timeout = intval($after - $before);
             if ($timeout < (int) $this->NydusCanal_List["warp"][$warp]["cooltime"]) {
                 $player->sendMessage(TextFormat::RED . "워프 쿨타임이 아직 남았습니다!");
                 $player->sendMessage(TextFormat::RED . intval((int) $this->NydusCanal_List["warp"][$warp]["cooltime"] - $timeout) . "초 후에 이용가능합니다!");
                 return false;
             } else {
                 unset($this->customCooltime[$warp][$player->getName()]);
             }
         }
     }
     if (isset($this->timeout[$warp][$player->getName()])) {
         $player->sendMessage(TextFormat::DARK_AQUA . "[ 시간제한 ] 시간제한이 해제되었습니다.");
         $this->timeout[$warp]["cancel"][$player->getName()] = 1;
     }
     if (isset($this->NydusCanal_List["warp"][$warp]["timeout"])) {
         if (!isset($this->timeout[$warp][$player->getName()])) {
             $this->timeout[$warp][$player->getName()] = $player->add(2);
             $player->sendMessage(TextFormat::RED . "[ 주의 ] [ 시간제한 ] " . $this->NydusCanal_List["warp"][$warp]["timeout"] . "초 뒤에 이전 위치로 복귀됩니다!");
             $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "warpTimeout"], [$player, $warp]), 20 * $this->NydusCanal_List["warp"][$warp]["timeout"]);
         }
     }
     if (isset($this->NydusCanal_List["warp"][$warp]["price"]) and $this->checkEconomyAPI()) {
         if (isset(explode("+", $this->NydusCanal_List["warp"][$warp]["price"])[1])) {
             $this->economyAPI->addMoney($player, explode("+", $this->NydusCanal_List["warp"][$warp]["price"])[1]);
         } else {
             $myMoney = $this->economyAPI->myMoney($player);
             if ($myMoney - $this->NydusCanal_List["warp"][$warp]["price"] < 0) {
                 $player->sendMessage(TextFormat::DARK_AQUA . "[ 서버 ] 이동비용이 부족합니다, 워프불가능");
                 return false;
             }
             $this->economyAPI->reduceMoney($player, $this->NydusCanal_List["warp"][$warp]["price"]);
         }
     }
     $player->teleport(new Position($x, $y, $z, $level), $yaw, $pitch);
     $player->addEntityMotion(0, 0, 0.6, 0);
     $player->sendMessage(TextFormat::LIGHT_PURPLE . "[ 서버 ] " . $warp . " (으)로 워프 되었습니다");
     $this->particle($player);
     if (isset($this->NydusCanal_List["warp"][$warp]["price"]) and $this->checkEconomyAPI()) {
         if (isset(explode("+", $this->NydusCanal_List["warp"][$warp]["price"])[1])) {
             $player->sendMessage(TextFormat::DARK_AQUA . "[ 서버 ] 보상금액 " . $this->NydusCanal_List["warp"][$warp]["price"] . "\$ 가 지급되었습니다.");
         } else {
             $player->sendMessage(TextFormat::DARK_AQUA . "[ 서버 ] 워프비용 " . $this->NydusCanal_List["warp"][$warp]["price"] . "\$ 가 지불되었습니다.");
         }
     }
 }
开发者ID:Gumbrat,项目名称:Pocketmine-Plugins,代码行数:92,代码来源:AdvancedWarps.php


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