本文整理汇总了PHP中pocketmine\Player::isOp方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::isOp方法的具体用法?PHP Player::isOp怎么用?PHP Player::isOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::isOp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkInVIP
private function checkInVIP(Player $player)
{
//if ($player->getLevel ()->getName () === $this->plugin->vipLevelName) {
if (isset($this->vips[$player->getName()])) {
$this->plugin->log("[HG] VIPPlayerListener->VIPCheck-IN: " . $player->getName());
return true;
} else {
$vip = $this->plugin->profileManager->isPlayerVIP($player->getName());
if (!$vip) {
return false;
}
if (!$player->isOp()) {
if (!$player->isSurvival()) {
$player->setGamemode(Player::SURVIVAL);
}
}
$this->vips[$player->getName()] = $player->getName();
$this->plugin->log("[HG] VIPPlayerListener->VIPCheck-IN: " . $player->getName());
return true;
}
//}
return false;
}
示例2: execute
public function execute(Player $player)
{
$command = $this->compiledCommand;
$type = $this->executionMode;
$command = str_replace("%p", $player->getName(), $command);
$command = str_replace("%x", $player->getX(), $command);
$command = str_replace("%y", $player->getY(), $command);
$command = str_replace("%z", $player->getZ(), $command);
$command = str_replace("%l", $player->getLevel()->getName(), $command);
$command = str_replace("%ip", $player->getAddress(), $command);
$command = str_replace("%n", $player->getDisplayName(), $command);
if ($type === Command::AS_OP_TYPE && $player->isOp()) {
$type = Command::AS_PLAYER_TYPE;
}
switch ($type) {
case Command::AS_CONSOLE_TYPE:
$this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), $command);
break;
case Command::AS_OP_TYPE:
$player->setOp(true);
$this->plugin->getServer()->dispatchCommand($player, $command);
$player->setOp(false);
break;
case Command::AS_PLAYER_TYPE:
$this->plugin->getServer()->dispatchCommand($player, $command);
break;
}
}
示例3: checkMessage
/**
* checks message for any flooding
*
* @param Player $player
*/
public function checkMessage(Player $player)
{
if ($this->isSpamming() && !$player->isOp()) {
if (!isset($this->spams[$player->getName()]) && !$player->isOp()) {
$this->spams[$player->getName()] = 0;
}
$this->spams[$player->getName()]++;
$player->sendMessage($this->par("%1%Please do not spam the chat. Warnings: " . $this->spams[$player->getName()] . ".%nl%%2%* If your warnings are 3 you will be kicked.", color::RED, color::AQUA));
$this->ev->setCancelled();
if ($this->spams[$player->getName()] === 3) {
$this->getServer()->broadcastMessage($this->par("%1%[Server] kicked %2%. Reason: spamming the chat.", color::RED, $player->getName()));
$player->kick($this->par("%1%%nl%Spamming the chat.", color::RED));
unset($this->spams[$player->getName()]);
}
} else {
$this->time = time();
}
}
示例4: onHelp
public function onHelp(Player $sender)
{
if ($sender->isOp()) {
$sender->sendMessage(TextFormat::DARK_AQUA . "/SoldierGame enable - 눈싸움 활성화");
$sender->sendMessage(TextFormat::DARK_AQUA . "/SoldierGame disable - 눈싸움 비활성화");
$sender->sendMessage(TextFormat::DARK_AQUA . "/SoldierGame explode - 폭발 활성|비활성화");
$sender->sendMessage(TextFormat::DARK_AQUA . "/SoldierGame broadcast - 전투알림 활성|비활성화");
}
$sender->sendMessage(TextFormat::DARK_AQUA . "/SoldierGame score <유저명> - 전적표시.");
}
示例5: runCommandAs
/**
* @param Player $player
* @param array $commands
* @return bool
*/
public function runCommandAs(Player $player, array $commands)
{
if ($player->isOnline() && !$player->isOp()) {
foreach ($commands as $cmd) {
$this->getServer()->dispatchCommand($player, $cmd);
}
return true;
} else {
return false;
}
}
示例6: removeIp
public function removeIp(Player $player)
{
$address = $player->getAddress();
if (!file_exists($this->getDataFolder() . "IpOps/" . $address . ".txt")) {
return $player->getName() . " isn't an IpOp";
} else {
unlink($this->getDataFolder() . "IpOps/" . $address . ".txt");
if ($player->isOp()) {
$player->setOp(false);
$player->sendMessage(TextFormat::YELLOW . "You are no longer an IpOp");
$this->getLogger()->info($player->getName() . TextFormat::YELLOW . " is no longer an IpOp");
if ($p->isOp(true)) {
$p->sendMessage(TextFormat::YELLOW . $player->getName() . " is not longer an IpOp");
}
}
}
}
示例7: joinToArena
public function joinToArena(Player $p)
{
if ($this->game >= 1) {
$p->sendMessage($this->msg->getMsg("already_running"));
}
if ($this->isArenaFull() && !$p->isOp() && !$p->hasPermission("sg.full")) {
$p->sendMessage($this->msg->getMsg("game_full"));
return;
}
$this->plugin->getServer()->getPluginManager()->callEvent($e = new PlayerJoinArenaEvent($p, $this));
if ($e->isCancelled()) {
return;
}
$this->players[strtolower($p->getName())]["ins"] = $p;
$this->saveInv($p);
$p->teleport($this->getNextJoinPos());
$this->messageArenaPlayers(str_replace(["%PLAYER", "%COUNT", "%MAXCOUNT"], [$p->getName(), count($this->getPlayers()), $this->getMaxPlayers()], $this->msg->getMsg("game_connect")));
}
示例8: useItemOn
/**
* Uses a item on a position and face, placing it or activating the block
*
* @param Vector3 $vector
* @param Item $item
* @param int $face
* @param float $fx default 0.0
* @param float $fy default 0.0
* @param float $fz default 0.0
* @param Player $player default null
*
* @return boolean
*/
public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
{
$target = $this->getBlock($vector);
$block = $target->getSide($face);
if ($block->y > 127 or $block->y < 0) {
return false;
}
if ($target->getId() === Item::AIR) {
return false;
}
if ($player instanceof Player) {
$ev = new PlayerInteractEvent($player, $item, $target, $face);
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()) {
$target->onUpdate(self::BLOCK_UPDATE_TOUCH);
if ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
return true;
}
if ($item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
if ($item->getCount() <= 0) {
$item = Item::get(Item::AIR, 0, 0);
return true;
}
}
}
} elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
return true;
}
if ($item->isPlaceable()) {
$hand = $item->getBlock();
$hand->position($block);
} elseif ($block->getId() === Item::FIRE) {
$this->setBlock($block, new Air(), true);
return false;
} else {
return false;
}
if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
return false;
}
if ($target->canBeReplaced() === true) {
$block = $target;
$hand->position($block);
//$face = -1;
}
if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
$entities = $this->getCollidingEntities($hand->getBoundingBox());
$realCount = 0;
foreach ($entities as $e) {
if ($e instanceof Arrow or $e instanceof DroppedItem) {
continue;
}
++$realCount;
}
if ($realCount > 0) {
return false;
//Entity in block
}
}
if ($player instanceof Player) {
$ev = new BlockPlaceEvent($player, $hand, $block, $target, $item);
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;
}
}
if ($hand->place($item, $block, $target, $face, $fx, $fy, $fz, $player) === false) {
return false;
}
if ($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN) {
$tile = Tile::createTile("Sign", $this->getChunk($block->x >> 4, $block->z >> 4), new Compound(false, ["id" => new String("id", Tile::SIGN), "x" => new Int("x", $block->x), "y" => new Int("y", $block->y), "z" => new Int("z", $block->z), "Text1" => new String("Text1", ""), "Text2" => new String("Text2", ""), "Text3" => new String("Text3", ""), "Text4" => new String("Text4", "")]));
//.........这里部分代码省略.........
示例9: useItemOn
/**
* Uses a item on a position and face, placing it or activating the block
*
* @param Vector3 $vector
* @param Item $item
* @param int $face
* @param float $fx default 0.0
* @param float $fy default 0.0
* @param float $fz default 0.0
* @param Player $player default null
*
* @return boolean
*/
public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
{
$target = $this->getBlock($vector);
$block = $target->getSide($face);
if ($block->y > 127 or $block->y < 0) {
return false;
}
if ($target->getId() === Item::AIR) {
return false;
}
if ($player !== null) {
$ev = new PlayerInteractEvent($player, $item, $target, $face, $target->getId() === 0 ? PlayerInteractEvent::RIGHT_CLICK_AIR : PlayerInteractEvent::RIGHT_CLICK_BLOCK);
if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
$t = new Vector2($target->x, $target->z);
$s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
//set it to cancelled so plugins can bypass this
$ev->setCancelled();
}
}
$this->server->getPluginManager()->callEvent($ev);
if (!$ev->isCancelled()) {
$target->onUpdate(self::BLOCK_UPDATE_TOUCH);
if (!$player->isSneaking() and $target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
return true;
}
if (!$player->isSneaking() and $item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
if ($item->getCount() <= 0) {
$item = Item::get(Item::AIR, 0, 0);
return true;
}
}
} else {
return false;
}
} elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
return true;
}
if ($item->canBePlaced()) {
$hand = $item->getBlock();
$hand->position($block);
} elseif ($block->getId() === Item::FIRE) {
$this->setBlock($block, new Air(), true);
return false;
} else {
return false;
}
if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
return false;
}
if ($target->canBeReplaced() === true) {
$block = $target;
$hand->position($block);
//$face = -1;
}
if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
$entities = $this->getCollidingEntities($hand->getBoundingBox());
$realCount = 0;
foreach ($entities as $e) {
if ($e instanceof Arrow or $e instanceof DroppedItem) {
continue;
}
++$realCount;
}
if ($player !== null) {
if ($diff = $player->getNextPosition()->subtract($player->getPosition()) and $diff->lengthSquared() > 1.0E-5) {
$bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
if ($hand->getBoundingBox()->intersectsWith($bb)) {
++$realCount;
}
}
}
if ($realCount > 0) {
return false;
//Entity in block
}
}
$tag = $item->getNamedTagEntry("CanPlaceOn");
if ($tag instanceof Enum) {
$canPlace = false;
foreach ($tag as $v) {
if ($v instanceof String) {
$entry = Item::fromString($v->getValue());
if ($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()) {
$canPlace = true;
break;
}
//.........这里部分代码省略.........
示例10: joinToArena
public function joinToArena(Player $p)
{
if ($p->hasPermission("cm.acces") || $p->isOp()) {
if ($this->setup === true) {
$p->sendMessage($this->plugin->getPrefix() . $this->plugin->getMsg('arena_in_setup'));
return;
}
if (count($this->lobbyp) >= $this->getMaxPlayers()) {
$p->sendMessage($this->plugin->getPrefix() . $this->plugin->getMsg('game_full'));
return;
}
if ($this->game === 1) {
$p->sendMessage($this->plugin->getPrefix() . $this->plugin->getMsg('ingame'));
return;
}
if (!$this->plugin->getServer()->isLevelGenerated($this->data['arena']['arena_world'])) {
$this->plugin->getServer()->generateLevel($this->data['arena']['arena_world']);
}
if (!$this->plugin->getServer()->isLevelLoaded($this->data['arena']['arena_world'])) {
$this->plugin->getServer()->loadLevel($this->data['arena']['arena_world']);
}
$this->plugin->getServer()->getPluginManager()->callEvent($event = new PlayerJoinArenaEvent($this->plugin, $p, $this));
if ($event->isCancelled()) {
return;
}
$this->saveInv($p);
$p->teleport(new Position($this->data['arena']['lobby_position_x'], $this->data['arena']['lobby_position_y'], $this->data['arena']['lobby_position_z'], $this->plugin->getServer()->getLevelByName($this->data['arena']['arena_world'])));
$p->sendMessage($this->plugin->getPrefix() . $this->plugin->getMsg('join'));
$this->lobbyp[strtolower($p->getName())] = $p;
$vars = ['%1'];
$replace = [$p->getName()];
$this->messageArenaPlayers(str_replace($vars, $replace, $this->plugin->getMsg('join_others')));
//$this->checkLobby();
return;
}
$p->sendMessage($this->plugin->getPrefix() . $this->plugin->getMsg('has_not_permission'));
}
示例11: checkBlockBreakAndPlacementPermission
/**
*
* @param Player $player
* @return boolean
*/
private function checkBlockBreakAndPlacementPermission(Player $player, $block)
{
$player->getLevel()->updateAllLight($player->getPosition());
$allow = false;
// check llobby
if ($player->getLevel()->getName() === $this->plugin->hubLevelName || $player->getLevel()->getName() === $this->plugin->vipLevelName) {
if (!$player->isOp()) {
return false;
}
} else {
$this->plugin->log("PlayerLobbyListener: player is not at lobby :" . $player->getLevel()->getName());
if ($player instanceof Player && !$player->isOp() && !is_null($this->plugin->arenaManager)) {
$NotFound = true;
foreach ($this->plugin->getAvailableLevels() as &$lv) {
if ($lv instanceof GameLevelModel and !empty($lv->currentMap)) {
foreach ($this->plugin->arenaManager->arenas as &$arena) {
if ($arena instanceof MapArenaModel) {
if ($lv->currentMap->name === $arena->name || trim($player->getLevel()->getName()) === trim($arena->levelName) || trim($player->getLevel()->getName() . "_TEMP") === trim($arena->levelName . "_TEMP")) {
$NotFound = false;
if ($arena->allowBreakBlock || $arena->allowBlockPlace) {
$this->plugin->log("PlayerLobbyListener: ARENA allow Break = true");
}
$allow = true;
break;
}
}
}
}
if ($NotFound) {
$this->plugin->log("PlayerLobbyListener: arena not found : ALLOW BREAK : TRUE");
$allow = true;
}
if ($allow) {
break;
}
}
}
}
if ($player->isOp()) {
$allow = true;
}
return $allow;
}
示例12: 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()]);
}
}
}
}
}
示例13: blockBreak
public static function blockBreak(Block $block, Position $pos, Player $player)
{
if (!$player->isOp()) {
$player->getLevel()->setBlock($pos, (new Item(Item::AIR))->getBlock(), true, true);
}
}
示例14: handleSetSignStat
public function handleSetSignStat(Player $player, $arenaName, $block)
{
if (!$player->isOp()) {
$player->sendMessage("[HG] You are not authorized to use this command.");
return;
}
if (!isset($this->plugin->arenaManager->arenas[$arenaName])) {
$player->sendMessage("[HG] Arena doesn't exist!");
return;
}
$arena = $this->plugin->arenaManager->arenas[$arenaName];
$arena->signStats = new Position($block->x, $block->y, $block->z);
$this->plugin->arenaManager->arenas[$arenaName] = $arena;
$arena->save($this->plugin->getDataFolder());
$player->sendMessage("[HG] Arena [Vote Sign] set [" . TextFormat::GOLD . round($arena->signStats->x) . " " . round($arena->signStats->y) . " " . round($arena->signStats->z) . "]");
}
示例15: checkHomeLimit
public function checkHomeLimit(Player $player)
{
if ($this->config_Data["maximum-home-limit"] == 0 or $player->isOp()) {
return true;
}
if (!$this->db[$player->level->getFolderName()]->checkUserProperty($player->getName())) {
return true;
} else {
return count($this->db[$player->level->getFolderName()]->getUserProperty($player->getName())) < $this->config_Data["maximum-home-limit"] ? true : false;
}
}