本文整理汇总了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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例5: getGamemode
public function getGamemode(Player $player)
{
return $player->getGamemode();
}
示例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;
}
}
示例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;
}
示例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;
}
示例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());
}
}
}
}
}
示例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;
}