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


PHP Player::getGamemode方法代码示例

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


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

示例1: handle

 private function handle($cmd, $args, Player $player, CommandSender $issuer)
 {
     switch ($cmd) {
         case "getping":
             $issuer->sendMessage("Ping of " . $player->getName() . ": unknown ms");
             return true;
         case "seearmor":
             $issuer->sendMessage("Armor of " . $player->getName() . ":");
             $issuer->sendMessage("Helmet: " . $this->formatItem($player->getInventory()->getArmorItem(0)));
             $issuer->sendMessage("Chestplate: " . $this->formatItem($player->getInventory()->getArmorItem(1)));
             $issuer->sendMessage("Leggings: " . $this->formatItem($player->getInventory()->getArmorItem(2)));
             $issuer->sendMessage("Boots: " . $this->formatItem($player->getInventory()->getArmorItem(3)));
             return true;
         case "seegm":
             $issuer->sendMessage("Gamemode of " . $player->getName() . ": " . $this->formatGamemode($player->getGamemode()));
             return true;
         case "getpos":
             $issuer->sendMessage($player->getName() . " is at (" . TextFormat::YELLOW . $player->x . ", " . TextFormat::GREEN . $player->y . ", " . TextFormat::AQUA . $player->z . ") in world " . TextFormat::RED . $player->getLevel()->getName() . ".");
             return true;
         case "setarmor":
             // TODO
             break;
         case "rmarmor":
             // TODO
             break;
         case "sessions":
             // TODO
             break;
     }
     return false;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:31,代码来源:InfoEss.php

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

示例3: showGameMode

 private function showGameMode(Player $player)
 {
     $modeName = "";
     switch ($player->getGamemode()) {
         case Player::ADVENTURE:
             $modeName = "Adventure";
             break;
         case Player::CREATIVE:
             $modeName = "Creative";
             break;
         case Player::SURVIVAL:
             $modeName = "Survival";
             break;
         case Player::SPECTATOR:
             $modeName = "Spectator";
             break;
     }
     $player->sendMessage(TextFormat::DARK_GRAY . "[HG] You are in mode: " . TextFormat::DARK_GREEN . $modeName);
 }
开发者ID:robozeri,项目名称:SG,代码行数:19,代码来源:PlayerWelcomeListener.php

示例4: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         $furnace = false;
         if ($t instanceof Furnace) {
             $furnace = $t;
         } else {
             $nbt = new Compound(false, [new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (($player->getGamemode() & 0x1) === 0x1) {
             return true;
         }
         $player->addWindow($furnace->getInventory());
     }
     return true;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:19,代码来源:BurningFurnace.php

示例5: getGamemode

 public function getGamemode(Player $player)
 {
     return $player->getGamemode();
 }
开发者ID:TDMGamingMC,项目名称:HungerSimulator,代码行数:4,代码来源:EventPlayer.php

示例6: addPlayer

 public function addPlayer(Player $player)
 {
     if ($this->enabled == true) {
         if ($this->active == false) {
             if (count($this->players) < $this->plugin->getConfig()->get("maxplayers")) {
                 $this->players[$player->getName()] = $player;
                 if (isset($this->players[$player->getName()])) {
                     $player->arena = $this;
                     $player->teleport($this->getSpawn());
                     $player->prevGamemode = $player->getGamemode();
                     $player->setGamemode(0);
                     $player->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Joined arena '" . $this->getArenaName() . "'");
                     return true;
                 } else {
                     $player->sendMessage("Error while joining...");
                     return false;
                 }
             } else {
                 $player->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "This arena is full");
                 return false;
             }
         } else {
             $player->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "A game is already running in this arena.");
         }
     } else {
         $player->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "This arena is disabled.");
         return false;
     }
 }
开发者ID:Skull3x,项目名称:WonderCore,代码行数:29,代码来源:Arena.php

示例7: hasItemPlayer

 /**
  * @param Player $player
  * @param Item $item
  * @return boolean
  */
 private function hasItemPlayer(Player $player, Item $item)
 {
     if ($this->SignShop->getProvider()->getPlayer(strtolower($player->getName()))["authorized"] == "root") {
         return true;
     }
     $ris = 0;
     if ($player->getGamemode() != 1) {
         for ($i = 0; $i <= $player->getInventory()->getSize(); ++$i) {
             $inv = $player->getInventory()->getItem($i);
             if ($inv->getID() == $item->getID() && $inv->getDamage() == $item->getDamage()) {
                 $ris = $ris + $inv->getCount();
             }
         }
     }
     if ($ris >= $item->getCount()) {
         return true;
     }
     return false;
 }
开发者ID:PocketMine-PHP7,项目名称:SignShop-PHP7,代码行数:24,代码来源:PlayerTouchEvent.php

示例8: setGamemode

 public function setGamemode(Player $player, $gm)
 {
     if ($gm < 0 or $gm > 3 or $player->gamemode === $gm) {
         return \false;
     }
     $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGameModeChangeEvent($player, (int) $gm));
     if ($ev->isCancelled()) {
         return false;
     }
     if (($player->gamemode & 0x1) === ($gm & 0x1)) {
         $player->gamemode = $gm;
         $player->sendMessage(TextFormat::DARK_AQUA . "게임모드가 변경되었습니다, " . Server::getGamemodeString($player->getGamemode()) . ".\n");
     } else {
         $player->gamemode = $gm;
         $player->sendMessage(TextFormat::DARK_AQUA . "게임모드가 변경되었습니다, " . Server::getGamemodeString($player->getGamemode()) . ".\n");
         $player->getInventory()->clearAll();
         $player->getInventory()->sendContents($player->getViewers());
         $player->getInventory()->sendHeldItem($player->getViewers());
     }
     $player->namedtag->playerGameType = new Int("playerGameType", $player->gamemode);
     $player->sendMessage(TextFormat::DARK_AQUA . "새 게임모드 적용을 위해 서버에서 킥처리됩니다.");
     $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "Kick"], [$player]), 50);
     return true;
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:24,代码来源:GameModeKick.php

示例9: clearAllInventories

 public static function clearAllInventories(Player $player)
 {
     if ($player != null && !$player->isOp()) {
         if ($player->getGamemode() === Player::SURVIVAL) {
             if (!empty($player->getInventory())) {
                 $player->getInventory()->setBoots(new Item(Item::AIR));
                 $player->getInventory()->setChestplate(new Item(Item::AIR));
                 $player->getInventory()->setHelmet(new Item(Item::AIR));
                 $player->getInventory()->setLeggings(new Item(Item::AIR));
                 $player->getInventory()->clearAll();
                 $player->getInventory()->setItemInHand(new Item(Item::AIR));
                 $player->getInventory()->sendContents($player);
                 if (!empty($player->getViewers())) {
                     $player->getInventory()->sendContents($player->getViewers());
                 }
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:19,代码来源:HungerGameKit.php

示例10: useBreakOn

 /**
  * Tries to break a block using a item, including Player time checks if available
  * It'll try to lower the durability if Item is a tool, and set it to Air if broken.
  *
  * @param Vector3 $vector
  * @param Item    &$item (if null, can break anything)
  * @param Player  $player
  *
  * @return boolean
  */
 public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null)
 {
     $target = $this->getBlock($vector);
     //TODO: Adventure mode checks
     if ($item === null) {
         $item = Item::get(Item::AIR, 0, 0);
     }
     if ($player instanceof Player) {
         $ev = new BlockBreakEvent($player, $target, $item, ($player->getGamemode() & 0x1) === 1 ? true : false);
         if ($player->isSurvival() and $item instanceof Item and !$target->isBreakable($item)) {
             $ev->setCancelled();
         }
         if (!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if ($t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
         $breakTime = $player->isCreative() ? 0.15 : $target->getBreakTime($item);
         if (!$ev->getInstaBreak() and $player->lastBreak + $breakTime >= microtime(true)) {
             return false;
         }
         $player->lastBreak = microtime(true);
     } elseif ($item instanceof Item and !$target->isBreakable($item)) {
         return false;
     }
     $level = $target->getLevel();
     if ($level instanceof Level) {
         $above = $level->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
         if ($above instanceof Block) {
             if ($above->getId() === Item::FIRE) {
                 $level->setBlock($above, new Air(), true);
             }
         }
     }
     $drops = $target->getDrops($item);
     //Fixes tile entities being deleted before getting drops
     $target->onBreak($item);
     $tile = $this->getTile($target);
     if ($tile instanceof Tile) {
         if ($tile instanceof InventoryHolder) {
             if ($tile instanceof Chest) {
                 $tile->unpair();
             }
             foreach ($tile->getInventory()->getContents() as $chestItem) {
                 $this->dropItem($target, $chestItem);
             }
         }
         $tile->close();
     }
     if ($item instanceof Item) {
         $item->useOn($target);
         if ($item->isTool() and $item->getDamage() >= $item->getMaxDurability()) {
             $item = Item::get(Item::AIR, 0, 0);
         }
     }
     if (!$player instanceof Player or $player->isSurvival()) {
         foreach ($drops as $drop) {
             if ($drop[2] > 0) {
                 $this->dropItem($vector->add(0.5, 0.5, 0.5), Item::get(...$drop));
             }
         }
     }
     return true;
 }
开发者ID:RedstoneAlmeida,项目名称:Steadfast2,代码行数:81,代码来源:Level.php


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