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


PHP Player::getPosition方法代码示例

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


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

示例1: __construct

 public function __construct(SimpleWarp $plugin, Warp $warp, Player $player)
 {
     parent::__construct($plugin);
     $this->warp = $warp;
     $this->player = $player;
     $this->position = $player->getPosition();
 }
开发者ID:TBNRFrags2468,项目名称:Economy,代码行数:7,代码来源:PlayerWarpTask.php

示例2: onRun

 public function onRun(array $args, Player $player)
 {
     $global = false;
     $anchor = $player->getPosition();
     $name = isset($args[0]) ? array_shift($args) : "default";
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "g":
                 $global = $this->getMain()->getClipboardProvider();
                 break;
             case "a":
             case "anchor":
                 $anchor = $this->getMain()->getAnchor($player);
                 break;
         }
     }
     if ($global instanceof ClipboardProvider) {
         $clip = $global[$name];
     } else {
         $clip = $this->getMain()->getClip($player, $name);
     }
     if (!$clip instanceof Clip) {
         if ($global instanceof ClipboardProvider) {
             return "There isn't a global clip called {$name}!";
         } else {
             return "You don't have a clip called {$name}!";
         }
     }
     $clip->paste($anchor);
     return count($clip->getBlocks()) . " block(s) have been pasted.";
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:32,代码来源:Paste.php

示例3: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($player === null or $player->isSurvival() !== true) {
         return false;
     }
     if ($target->getId() === Block::STILL_WATER or $target->getId() === Block::WATER) {
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $target, $this));
         if ($ev->isCancelled()) {
             return false;
         } else {
             if ($this->count <= 1) {
                 $player->getInventory()->setItemInHand(Item::get(Item::POTION, 0, 1));
                 return true;
             } else {
                 $this->count--;
                 $player->getInventory()->setItemInHand($this);
             }
             if ($player->getInventory()->canAddItem(Item::get(Item::POTION, 0, 1)) === true) {
                 $player->getInventory()->AddItem(Item::get(Item::POTION, 0, 1));
             } else {
                 $motion = $player->getDirectionVector()->multiply(0.4);
                 $position = clone $player->getPosition();
                 $player->getLevel()->dropItem($position->add(0, 0.5, 0), Item::get(Item::POTION, 0, 1), $motion, 40);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:29,代码来源:GlassBottle.php

示例4: onRun

 public function onRun(array $args, Player $player)
 {
     $mode = 0;
     $target = $player->getPosition();
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "c":
             case "crosshair":
                 $target = WorldEditArt::getCrosshairTarget($player);
                 if (!$target instanceof Block) {
                     return "The block is too far/in the void/sky!";
                 }
                 break;
             case "v":
             case "view":
                 $mode = 1;
                 break;
         }
     }
     switch ($mode) {
         case 0:
             $this->getMain()->setAnchor($player, $target);
             return "Your anchor has been set to " . WorldEditArt::posToStr($target) . ".";
         case 1:
             $anchor = $this->getMain()->getAnchor($player);
             if (!$anchor instanceof Position) {
                 return "You don't have an anchor selected!";
             }
             return "Your anchor is at " . WorldEditArt::posToStr($anchor) . ".";
         default:
             return null;
     }
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:34,代码来源:Anchor.php

示例5: 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

示例6: storePlayer

 public function storePlayer(Player $player)
 {
     if (!isset($this->players[$player->getName()])) {
         $this->players[$player->getName()] = ["inventory" => serialize($player->getInventory()->getContents()), "armor" => serialize($player->getInventory()->getArmorContents()), "spawn" => serialize($player->getPosition()), "gamemode" => $player->getGamemode()];
         $player->setGamemode(0);
         $player->getInventory()->clearAll();
     }
 }
开发者ID:EmreTr1,项目名称:TNTRun,代码行数:8,代码来源:PlayerData.php

示例7: onRun

 public function onRun(array $args, Space $space, Player $player)
 {
     $anchor = $player->getPosition();
     if (isset($args[0]) and ($args[0] === "-a" or $args[0] === "-anchor")) {
         $anchor = $this->getMain()->getAnchor($player);
     }
     if (!isset($args[0])) {
         array_unshift($args, "default");
     }
     $clip = new Clip($space, $anchor, array_shift($args));
     if (isset($args[0]) and ($args[0] === "g" or $args[0] === "global")) {
         $clipboard = $this->getMain()->getClipboardProvider();
         $clipboard[$clip->getName()] = $clip;
     } else {
         $this->getMain()->setClip($player, $clip, $clip->getName());
     }
     return "Clip " . $clip->getName() . " copied.";
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:18,代码来源:Copy.php

示例8: addPlayerFireworks

 public static function addPlayerFireworks(Player $player, Position $pos1, $count = 5)
 {
     $pos = new Position($player->getPosition()->x, $player->getPosition()->y + 3, $player->getPosition()->z, $player->getLevel());
     $pos2 = new Position($player->getPosition()->x, $player->getPosition()->y + 1, $player->getPosition()->z, $player->getLevel());
     $exp = new Explosion($pos, 1);
     $exp->explodeB();
     MagicUtil::addParticles($player->getLevel(), "explode", $pos2);
     for ($i = 0; $i < 5; $i++) {
         $pos = new Position($pos1->x + rand(-2, 3), $pos1->y + rand(0, 5), $pos1->z + rand(-2, 3), $player->getLevel());
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
     }
     MagicUtil::addParticles($player->getLevel(), "driplava", $pos1);
 }
开发者ID:robozeri,项目名称:SG,代码行数:17,代码来源:MagicUtil.php

示例9: onRun

 public function onRun(array $args, Player $player)
 {
     if (!isset($args[0])) {
         return false;
     }
     $radius = floatval(array_shift($args));
     $anchor = $player->getPosition();
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "anchor":
                 $anchor = $this->getMain()->getAnchor($player);
                 if (!$anchor instanceof Position) {
                     return self::NO_ANCHOR;
                 }
                 break;
         }
     }
     $sel = new SphereSpace($anchor, $radius);
     $this->getMain()->setSelection($player, $sel);
     return "You have selected {$sel}.";
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:23,代码来源:Sphere.php

示例10: teleportToMap

 public static final function teleportToMap($levelname, Player $player)
 {
     if (!$player->getServer()->isLevelLoaded($levelname)) {
         $ret = $player->getServer()->loadLevel($levelname);
         if (!$ret) {
             $player->sendMessage("[HG]Error, unable load World: " . $levelname);
             return;
         }
     }
     if (!$player->getServer()->isLevelGenerated($levelname)) {
         $player->sendMessage("[HG] world generation is not ready! try later.");
         return;
     }
     $level = $player->getServer()->getLevelByName($levelname);
     if (is_null($level)) {
         $player->sendMessage("[HG] Error, unable access world: " . $levelname);
         return;
     }
     $player->getLevel()->updateAllLight($player->getPosition());
     $player->getLevel()->updateAround($player->getPosition());
     $player->teleport($level->getSafeSpawn());
 }
开发者ID:robozeri,项目名称:SG,代码行数:22,代码来源:MapPortal.php

示例11: handleTapOnArenaSigns

 /**
  *
  * Handle Tap On Arena Signs
  *
  * @param Player $player        	
  * @param unknown $b        	
  * @return boolean
  */
 public function handleTapOnArenaSigns(Player $player, $b)
 {
     foreach ($this->arenas as &$arena) {
         if ($arena instanceof MapArenaModel) {
             // tap on vote sign
             if (!empty($arena->signVote)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signVote->x) . "." . round($arena->signVote->y) . "." . round($arena->signVote->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     if (!$arena->published) {
                         $player->sendMessage("[HG] This map is not available yet! please try another one.");
                         break;
                     }
                     $players[] = $player;
                     $player->getLevel()->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "reddust", $arena->signVote, 20);
                     if ($arena->vote === 0 && isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                     }
                     if (!isset($arena->votedPlayers[$player->getName()])) {
                         $arena->vote++;
                         $arena->votedPlayers[$player->getName()] = $player;
                     } else {
                         $player->sendMessage(TextFormat::YELLOW . "[HG] Already voted! [" . $arena->displayName . "]");
                     }
                     $player->sendMessage(TextFormat::GRAY . "[HG] " . $arena->displayName . " map votes [" . TextFormat::YELLOW . $arena->vote . TextFormat::GRAY . "]");
                     break;
                 }
             }
             if (!empty($arena->signExit) && !empty($arena->arenaExitPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signExit->x) . "." . round($arena->signExit->y) . "." . round($arena->signExit->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->level->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                     unset($arena->joinedPlayers[$player->getName()]);
                     unset($arena->livePlayers[$player->getName()]);
                     $player->teleport($arena->arenaExitPos);
                     break;
                 }
             }
             if (!empty($arena->signJoin) && !empty($arena->arenaEnterPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signJoin->x) . "." . round($arena->signJoin->y) . "." . round($arena->signJoin->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->level->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                     MapPortal::teleportToMap($arena->levelName, $player);
                     $player->teleport($arena->arenaEnterPos);
                     break;
                 }
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:65,代码来源:MapArenaManager.php

示例12: addItem

 public function addItem(Item $item, Player $player, Item $result)
 {
     if ($item->getCount() <= 1) {
         $player->getInventory()->setItemInHand($result);
     } else {
         $item->setCount($item->getCount() - 1);
         if ($player->getInventory()->canAddItem($result) === true) {
             $player->getInventory()->addItem($result);
         } else {
             $motion = $player->getDirectionVector()->multiply(0.4);
             $position = clone $player->getPosition();
             $player->getLevel()->dropItem($position->add(0, 0.5, 0), $result, $motion, 40);
         }
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:15,代码来源:Cauldron.php

示例13: fire

 private function fire(Player $c, $fuse, $speed)
 {
     $pos = $c->getPosition();
     $pos->y += $c->getEyeHeight();
     $dir = $c->getDirectionVector();
     $dir->x = $dir->x * $speed;
     $dir->y = $dir->y * $speed;
     $dir->z = $dir->z * $speed;
     $this->scorchit($pos, $dir, $fuse);
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:10,代码来源:Main.php

示例14: onRun

 public function onRun(array $args, Player $player)
 {
     $flag = 0;
     // 0 for me, 1 for anchor, 2 for crosshair
     if (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "anchor":
                 $flag = 1;
                 break;
             case "c":
             case "crosshair":
                 $flag = 2;
                 break;
         }
     }
     $selected = $player->getPosition();
     if ($flag === 1) {
         $selected = $this->getMain()->getAnchor($player);
         if (!$selected instanceof Position) {
             return self::NO_ANCHOR;
         }
     }
     if ($flag === 2) {
         $selected = WorldEditArt::getCrosshairTarget($player);
         if (!$selected instanceof Position) {
             return "The block is too far/in the void/in the sky.";
         }
     }
     if ($selected->y < 0 or $selected->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "The selected point is too high/too low.";
     }
     $selected->getLevel()->loadChunk($selected->x >> 4, $selected->z >> 4);
     $selected = Position::fromObject($selected->floor(), $selected->getLevel());
     $space = $this->getMain()->getSelection($player);
     if ($space instanceof CuboidSpace and $space->getLevel() === $selected->getLevel()) {
         if ($this->is2) {
             $space->set1($selected);
         } else {
             $space->set0($selected);
         }
         goto end;
     }
     $temp = $this->getMain()->getTempPos($player);
     if (is_array($temp) and $temp["#"] !== $this->is2) {
         /** @var Position $pos */
         $pos = $temp["position"];
         if ($pos->getLevel() === $selected->getLevel()) {
             if ($this->is2) {
                 $this->getMain()->setSelection($player, new CuboidSpace($pos, $selected));
             } else {
                 $this->getMain()->setSelection($player, new CuboidSpace($selected, $pos));
             }
             goto end;
         }
     }
     $this->getMain()->unsetSelection($player);
     $this->getMain()->setTempPos($player, $selected, $this->is2);
     end:
     $space = $this->getMain()->getSelection($player);
     if ($space instanceof Space) {
         $cnt = count($space);
     }
     return ($this->is2 ? "Second" : "First") . " position set to " . "({$selected->x}, {$selected->y}, {$selected->z})." . (isset($cnt) ? "\n  (Cuboid selected with {$cnt} blocks)" : "");
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:66,代码来源:PosSubcommand.php

示例15: portalEnter

 /**
  *
  * @param GameLevelModel $lv        	
  * @param Player $player        	
  * @return boolean
  */
 public function portalEnter(HungerGamesPlugIn $plugin, GameLevelModel $lv, Player $player)
 {
     if ($player->getLevel()->getName() != $lv->levelName) {
         return true;
     }
     if ($lv->insideLevelEntracePortal($player->getPosition())) {
         if (!isset($this->joinedPlayers[$player->getName()])) {
             if ($plugin->storyenforceaccess && $lv->type != 1) {
                 $w = $plugin->storyManager->hasPlayerWonLevel($player->getName(), $lv->type - 1);
                 if (!$w) {
                     $player->sendMessage(TextFormat::RED . "[HG Story Mode Enabled]");
                     $player->sendMessage(TextFormat::YELLOW . "Required " . TextFormat::GOLD . "WIN " . TextFormat::YELLOW . "previous level before play this level!");
                     $player->getLevel()->addSound(new LaunchSound($player->getPosition()), array($player));
                     if ($player->isOp()) {
                         $player->sendMessage(TextFormat::AQUA . "[Admin BY-PASS Story Mode Checking]");
                     } else {
                         $player->teleport($lv->enterpos);
                         return;
                     }
                 }
             }
             $this->joinedPlayers[$player->getName()] = $player;
             $message = TextFormat::GRAY . "[HG] [" . TextFormat::AQUA . $player->getName() . TextFormat::GRAY . "] joined " . $lv->displayName . " [" . TextFormat::GREEN . count($lv->joinedPlayers) . TextFormat::GRAY . " |" . TextFormat::WHITE . "minimal " . TextFormat::YELLOW . $lv->minPlayers . TextFormat::GRAY . "]";
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player->getPosition()), $lv->joinedPlayers);
             $effect = MagicUtil::addEffect($player, Effect::STRENGTH);
             if ($effect != null) {
                 $this->playersWithEffects[$player->getName()] = $effect;
             }
             if (!$player->isOp()) {
                 if (!$player->isSurvival()) {
                     $player->setGamemode(Player::SURVIVAL);
                 }
             }
             $player->sendMessage(TextFormat::YELLOW . "[HG] Please wait here");
             $player->sendMessage(TextFormat::GRAY . "[HG] The game auto start with minimal players");
         }
     } else {
         if (isset($this->joinedPlayers[$player->getName()])) {
             $message = TextFormat::GRAY . "[ " . $player->getName() . " ] left " . $lv->displayName;
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player), $lv->joinedPlayers);
             unset($this->joinedPlayers[$player->getName()]);
             if (count($this->joinedPlayers) < $lv->minPlayers) {
                 $lv->joinDownCounter = $lv->joinDownCounterReset;
             }
             foreach ($plugin->arenaManager->arenas as &$arena) {
                 if ($arena instanceof MapArenaModel) {
                     if (isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                         if ($arena->vote >= 1) {
                             $arena->vote--;
                         }
                         break;
                     }
                 }
             }
             if (isset($this->playersWithEffects[$player->getName()])) {
                 $effect = $this->playersWithEffects[$player->getName()];
                 if ($effect != null) {
                     $player->removeEffect($effect->getId());
                     unset($this->playersWithEffects[$player->getName()]);
                 }
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:73,代码来源:GameLevelModel.php


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