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


PHP level\Position类代码示例

本文整理汇总了PHP中pocketmine\level\Position的典型用法代码示例。如果您正苦于以下问题:PHP Position类的具体用法?PHP Position怎么用?PHP Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onEnable

 public function onEnable()
 {
     if (!file_exists($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     $this->saveDefaultConfig();
     $provider = $this->getConfig()->get("data-provider");
     switch (strtolower($provider)) {
         case "yaml":
             $this->provider = new YamlDataProvider($this->getDataFolder() . "Shops.yml", $this->getConfig()->get("auto-save"));
             break;
         default:
             $this->getLogger()->critical("Invalid data provider was given. EconomyShop will be terminated.");
             return;
     }
     $this->getLogger()->notice("Data provider was set to: " . $this->provider->getProviderName());
     $levels = [];
     foreach ($this->provider->getAll() as $shop) {
         if ($shop[9] !== -2) {
             if (!isset($levels[$shop[3]])) {
                 $levels[$shop[3]] = $this->getServer()->getLevelByName($shop[3]);
             }
             $pos = new Position($shop[0], $shop[1], $shop[2], $levels[$shop[3]]);
             $display = $pos;
             if ($shop[9] !== -1) {
                 $display = $pos->getSide($shop[9]);
             }
             $this->items[$shop[3]][] = new ItemDisplayer($display, Item::get($shop[4], $shop[5]), $pos);
         }
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->lang = json_decode(stream_get_contents($rsc = $this->getResource("lang_en.json")), true);
     // TODO: Language preferences
     @fclose($rsc);
 }
开发者ID:PocketMine-PHP7,项目名称:EconomyS-PHP7,代码行数:35,代码来源:EconomyShop.php

示例2: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (!$sender instanceof Player and count($args) < 4) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     if ($sender instanceof Player and count($args) < 4) {
         $pos = $sender->getPosition();
     } else {
         $level = $sender->getServer()->getLevelByName($args[3]);
         if (!$level instanceof Level) {
             $sender->sendMessage(TextFormat::RED . "Invalid level name");
             return false;
         }
         $pos = new Position((int) $args[0], (int) $args[1], (int) $args[2], $level);
     }
     if (!isset($args[4]) or $args[0] != "regenerate") {
         $chunk = $pos->getLevel()->getChunk($pos->x >> 4, $pos->z >> 4);
         McRegion::getRegionIndex($chunk->getX(), $chunk->getZ(), $x, $z);
         $sender->sendMessage("Region X: {$x} Region Z: {$z}");
     } elseif ($args[4] == "regenerate") {
         foreach ($sender->getServer()->getOnlinePlayers() as $p) {
             if ($p->getLevel() == $pos->getLevel()) {
                 $p->kick(TextFormat::AQUA . "A chunk of this chunk is regenerating, please re-login.", false);
             }
         }
         $pos->getLevel()->regenerateChunk($pos->x >> 4, $pos->z >> 4);
     }
     return true;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:33,代码来源:ChunkInfoCommand.php

示例3: onEnable

 public function onEnable()
 {
     $this->saveDefaultConfig();
     if (!$this->selectLang()) {
         $this->getLogger()->warning("Invalid language option was given.");
     }
     $provider = $this->getConfig()->get("data-provider");
     switch (strtolower($provider)) {
         case "yaml":
             $this->provider = new YamlDataProvider($this->getDataFolder() . "Sells.yml", $this->getConfig()->get("auto-save"));
             break;
         default:
             $this->getLogger()->critical("Invalid data provider was given. EconomySell will be terminated.");
             return;
     }
     $this->getLogger()->notice("Data provider was set to: " . $this->provider->getProviderName());
     $levels = [];
     foreach ($this->provider->getAll() as $sell) {
         if ($sell[9] !== -2) {
             if (!isset($levels[$sell[3]])) {
                 $levels[$sell[3]] = $this->getServer()->getLevelByName($sell[3]);
             }
             $pos = new Position($sell[0], $sell[1], $sell[2], $levels[$sell[3]]);
             $display = $pos;
             if ($sell[9] !== -1) {
                 $display = $pos->getSide($sell[9]);
             }
             $this->items[$sell[3]][] = new ItemDisplayer($display, Item::get($sell[4], $sell[5]), $pos);
         }
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
 }
开发者ID:dog194,项目名称:EconomyS,代码行数:32,代码来源:EconomySell.php

示例4: putPosition

 public function putPosition(Position $position)
 {
     $this->putLong($position->x);
     $this->putShort($position->y);
     $this->putLong($position->z);
     $this->putString($position->isValid() ? $position->getLevel()->getName() : "");
 }
开发者ID:Ad5001,项目名称:WorldEditArt,代码行数:7,代码来源:ByteBufferWriter.php

示例5: __construct

 public function __construct(Position $center, $size, $what = \null)
 {
     $this->level = $center->getLevel();
     $this->source = $center;
     $this->size = \max($size, 0);
     $this->what = $what;
 }
开发者ID:ken77731,项目名称:PocketMine-0.13.0,代码行数:7,代码来源:Explosion__64bit.php

示例6: startDuel

 /**
  * Really starts the duel after countdown
  */
 public function startDuel()
 {
     Server::getInstance()->getScheduler()->cancelTask($this->countdownTaskHandler->getTaskId());
     $player1 = $this->players[0];
     $player2 = $this->players[1];
     $pos_player1 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player1->x += self::PLAYER_1_OFFSET_X;
     $pos_player2 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player2->x += self::PLAYER_2_OFFSET_X;
     $player1->teleport($pos_player1, 90, 0);
     $player2->teleport($pos_player2, -90, 0);
     // Fix start time
     $this->startTime = new DateTime('now');
     $player1->sendTip(TextFormat::RED . "You are strarting a duel !");
     $player1->sendMessage(" ");
     $player1->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player1->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You're starting a duel against : " . $player2->getName() . " !");
     $player1->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You have 3min !");
     $player1->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " Good luck :) !");
     $player1->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player1->sendMessage(" ");
     $player1->sendTip(TextFormat::RED . "You are strarting a duel !");
     $player2->sendMessage(" ");
     $player2->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player2->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You're starting a duel against : " . $player1->getName() . " !");
     $player2->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You have 3min !");
     $player2->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " Good luck :) !");
     $player2->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player2->sendMessage(" ");
     // Launch the end round task
     $task = new RoundCheckTask(OneVsOne::getInstance());
     $task->arena = $this;
     $this->taskHandler = Server::getInstance()->getScheduler()->scheduleDelayedTask($task, self::ROUND_DURATION * 20);
 }
开发者ID:TDMGamingMC,项目名称:pocketmine-1vs1-plugin,代码行数:37,代码来源:Arena.php

示例7: startDuel

 /**
  * Really starts the duel after countdown
  */
 public function startDuel()
 {
     Server::getInstance()->getScheduler()->cancelTask($this->countdownTaskHandler->getTaskId());
     $player1 = $this->players[0];
     $player2 = $this->players[1];
     $pos_player1 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player1->x += self::PLAYER_1_OFFSET_X;
     $pos_player2 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player2->x += self::PLAYER_2_OFFSET_X;
     $player1->teleport($pos_player1, 90, 0);
     $player2->teleport($pos_player2, -90, 0);
     $this->sparyParticle($player1);
     $this->sparyParticle($player2);
     $player1->setGamemode(0);
     $player2->setGamemode(0);
     // Give kit
     foreach ($this->players as $player) {
         $this->giveKit($player);
     }
     // Fix start time
     $this->startTime = new DateTime('now');
     $player1->sendTip(OneVsOne::getMessage("duel_tip"));
     $player1->sendMessage(OneVsOne::getMessage("duel_start"));
     $player2->sendTip(OneVsOne::getMessage("duel_tip"));
     $player2->sendMessage(OneVsOne::getMessage("duel_start"));
     // Launch the end round task
     $task = new RoundCheckTask(OneVsOne::getInstance());
     $task->arena = $this;
     $this->taskHandler = Server::getInstance()->getScheduler()->scheduleDelayedTask($task, self::ROUND_DURATION * 20);
 }
开发者ID:Suppert,项目名称:pocketmine-1vs1-plugin,代码行数:33,代码来源:Arena.php

示例8: runNoteBlockSound

 public static function runNoteBlockSound(Position $pos, $pitch, $type = NoteBlock::PIANO_OR_HARP, $players = null)
 {
     if (!is_array($players)) {
         if ($players instanceof Player) {
             $players = [$players];
         } elseif ($players == null) {
             $players = $pos->getLevel()->getChunkPlayers($pos->x >> 4, $pos->z >> 4);
         } else {
             return false;
         }
     }
     $soundPk = new BlockEventPacket();
     $soundPk->x = $pos->x;
     $soundPk->y = $pos->y;
     $soundPk->z = $pos->z;
     $soundPk->case1 = $type;
     $soundPk->case2 = $pitch;
     $setNoteBlockPk = new UpdateBlockPacket();
     $setNoteBlockPk->records[] = [$pos->x, $pos->z, $pos->y, 25, 0, UpdateBlockPacket::FLAG_NONE];
     $realBlock = $pos->getLevel()->getBlock($pos);
     $setRealBlockPk = new UpdateBlockPacket();
     $setRealBlockPk->records[] = [$pos->x, $pos->z, $pos->y, $realBlock->getID(), $realBlock->getDamage(), UpdateBlockPacket::FLAG_NONE];
     Server::getInstance()->batchPackets($players, [$setNoteBlockPk, $soundPk, $setRealBlockPk], false);
     return true;
 }
开发者ID:organization,项目名称:AddNoteBlock,代码行数:25,代码来源:NoteBlock.php

示例9: setHome

 public function setHome(IPlayer $player, Position $pos)
 {
     $n = strtolower($player->getName());
     $l = "l-" . strtolower($pos->getLevel()->getName());
     $this->homes[$l][$n] = [$pos->getX(), $pos->getY(), $pos->getZ()];
     $this->saveHomes();
 }
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:7,代码来源:CmdHomes.php

示例10: __construct

 public function __construct(Position $center, $size, $what = null, bool $dropItem = true)
 {
     $this->level = $center->getLevel();
     $this->source = $center;
     $this->size = max($size, 0);
     $this->what = $what;
     $this->dropItem = $dropItem;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:8,代码来源:Explosion.php

示例11: operate

 public function operate(Position $anchor)
 {
     if (is_int($this->delta)) {
         throw new \BadMethodCallException("MacroOperation is of type TRUE (wait) not FALSE (operate) thus cannot be operated");
     }
     $anchor->getLevel()->setBlock($anchor->add($this->delta), $this->block, false, true);
     // update
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:8,代码来源:MacroOperation.php

示例12: savePosition

 public function savePosition(Position $pos, $pitch = 0, $yaw = 0)
 {
     $this->data["x"] = $pos->x;
     $this->data["y"] = $pos->y;
     $this->data["z"] = $pos->z;
     $this->data["pitch"] = $pitch;
     $this->data["yaw"] = $yaw;
     $this->data["levelName"] = $pos->getLevel()->getFolderName();
 }
开发者ID:JiangsNetworkAlpha,项目名称:JiangsNeather,代码行数:9,代码来源:LocationData.php

示例13: searchAreaByPosition

 /**
  * @param Position $pos
  * @return Area|null
  */
 public function searchAreaByPosition(Position $pos)
 {
     foreach ($this->getAreas() as $area) {
         $l = $area->getShape()->getLevelName();
         if ($l !== $pos->getLevel()->getName()) {
             continue;
         }
         if ($area->getShape()->isInside($pos)) {
             return $area;
         }
     }
     return null;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:17,代码来源:Database.php

示例14: isOnRadius

 /**
  * @param Position $position
  * @param $radius
  *
  * @return bool
  */
 public function isOnRadius(Position $position, $radius)
 {
     if ($this->minX - $radius <= $position->x && $position->x <= $this->maxX + $radius) {
         if ($this->minY - $radius <= $position->y && $position->y <= $this->maxY + $radius) {
             if ($this->minZ - $radius <= $position->z && $position->z <= $this->maxZ + $radius) {
                 if ($position->getLevel()->getName() === $this->levelName) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:Tee7even,项目名称:iZone,代码行数:19,代码来源:Zone.php

示例15: parseArenaPositions

 /**
  * Create arenas
  */
 public function parseArenaPositions(array $arenaPositions)
 {
     foreach ($arenaPositions as $n => $arenaPosition) {
         Server::getInstance()->loadLevel($arenaPosition[3]);
         if (($level = Server::getInstance()->getLevelByName($arenaPosition[3])) === null) {
             Server::getInstance()->getLogger()->error("[1vs1] - " . $arenaPosition[3] . " is not loaded. Arena " . $n . " is disabled.");
         } else {
             $newArenaPosition = new Position($arenaPosition[0], $arenaPosition[1], $arenaPosition[2], $level);
             $newArena = new Arena($newArenaPosition, $this);
             array_push($this->arenas, $newArena);
             Server::getInstance()->getLogger()->debug("[1vs1] - Arena " . $n . " loaded at position " . $newArenaPosition->__toString());
         }
     }
 }
开发者ID:bjorguv,项目名称:pocketmine-1vs1-plugin,代码行数:17,代码来源:ArenaManager.php


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