本文整理汇总了PHP中pocketmine\Player::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::hasPermission方法的具体用法?PHP Player::hasPermission怎么用?PHP Player::hasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::hasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canPlaceBreakBlock
public function canPlaceBreakBlock(Player $c, $world)
{
$pname = strtolower($c->getName());
if (isset($this->wcfg[$world]["auth"]) && count($this->wcfg[$world]["auth"])) {
// Check if user is in auth list...
if (isset($this->wcfg[$world]["auth"][$pname])) {
return true;
}
return false;
}
if ($c->hasPermission("wp.cmd.protect.auth")) {
return true;
}
return false;
}
示例2: hasSpectatePermission
public final function hasSpectatePermission(Player $player) : bool
{
foreach ($this->getSpectatePermissions() as $perm) {
if (!$player->hasPermission($perm)) {
return false;
}
}
return true;
}
示例3: hasPermission
public function hasPermission($permission)
{
return $this->player->hasPermission($permission);
}
示例4: onRun
public function onRun(PlayerEnt $entity, Player $player, array $args)
{
if (!isset($args[1])) {
return false;
}
$bank = isset($args[2]) and strtolower($args[2]) === "-bank";
if ($bank and !$player->hasPermission("xecon.cmd.pay.bank")) {
return "You don't have permission to pay bank money to other players.";
} elseif (!$bank and !$player->hasPermission("xecon.cmd.pay.cash")) {
return "You don't have permission to pay cash to other players.";
}
$toEnt = $this->getPlugin()->getPlayerEnt($args[0]);
if (!$toEnt instanceof PlayerEnt) {
return "Player {$args['0']} is not registered in the database!";
}
$to = $toEnt->getAccount($name = $bank ? PlayerEnt::ACCOUNT_BANK : PlayerEnt::ACCOUNT_CASH);
$from = $entity->getAccount($name);
$amount = floatval($args[1]);
if ($amount <= 0) {
return "Amount must be larger than zero!";
}
if (!$from->canPay($amount)) {
return "You cannot pay \${$amount} from your {$from} account.";
}
if (!$to->canReceive($amount)) {
return "{$args['0']}'s {$to} account cannot receive \${$amount}.";
}
$from->pay($to, $amount, implode(" ", array_slice($args, 2 + ($bank ? 1 : 0))));
return "Transaction completed: \${$amount} has been paid to {$args['1']}'s {$to} account from your {$from} account.";
}
示例5: onRun
/**
* @param int $currentTick
*/
public function onRun($currentTick)
{
$this->getPlugin()->getServer()->getLogger()->debug(TextFormat::YELLOW . "Running EssentialsPE's AFKKickTask");
if ($this->getPlugin()->isAFK($this->player) && !$this->player->hasPermission("essentials.afk.kickexempt") && time() - $this->getPlugin()->getLastPlayerMovement($this->player) >= $this->getPlugin()->getConfig()->getNested("afk.auto-set")) {
$this->player->kick("You have been kicked for idling more than " . (($time = floor($this->getPlugin()->getConfig()->getNested("afk.auto-kick"))) / 60 >= 1 ? $time / 60 . " minutes" : $time . " seconds"), false);
}
}
示例6: checkPermission
public function checkPermission(Space $space, Player $player)
{
if ($space instanceof CuboidSpace) {
return $player->hasPermission("wea.test.cuboid");
}
if ($space instanceof CylinderSpace) {
return $player->hasPermission("wea.test.cylinder");
}
if ($space instanceof SphereSpace) {
return $player->hasPermission("wea.test.sphere");
}
return $player->hasPermission("wea.test.*");
}
示例7: spawnTo
public function spawnTo(Player $player)
{
if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) {
$this->hasSpawned[$player->getLoaderId()] = $player;
$pk = new AddPlayerPacket();
$pk->uuid = $this->getUniqueId();
$pk->username = $this->getName();
$pk->eid = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->speedX = 0;
$pk->speedY = 0;
$pk->speedZ = 0;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$item = $this->getInventory()->getItemInHand();
$pk->item = $item;
if ($player->hasPermission("slapper.seeownskin")) {
$pk->skin = $player->getSkinData();
$pk->slim = $player->isSkinSlim();
} else {
$pk->skin = $this->skin;
$pk->slim = $this->isSlim;
}
$pk->metadata = [2 => [4, $this->getDataProperty(2)], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
$this->inventory->sendArmorContents($player);
}
}
示例8: spawnTo
public function spawnTo(Player $player)
{
if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) {
$this->hasSpawned[$player->getLoaderId()] = $player;
$uuid = $this->getUniqueId();
$entityId = $this->getId();
$pk = new AddPlayerPacket();
$pk->uuid = $uuid;
$pk->username = "";
$pk->eid = $entityId;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->item = $this->getInventory()->getItemInHand();
$pk->metadata = [2 => [4, str_ireplace("{name}", $player->getName(), str_ireplace("{display_name}", $player->getDisplayName(), $player->hasPermission("slapper.seeId") ? $this->getDataProperty(2) . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $entityId : $this->getDataProperty(2)))], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
$player->dataPacket($pk);
$this->inventory->sendArmorContents($player);
$add = new PlayerListPacket();
$add->type = 0;
$add->entries[] = [$uuid, $entityId, isset($this->namedtag->MenuName) ? $this->namedtag["MenuName"] : "", $this->skinName, $this->skin];
$player->dataPacket($add);
if ($this->namedtag["MenuName"] === "") {
$remove = new PlayerListPacket();
$remove->type = 1;
$remove->entries[] = [$uuid];
$player->dataPacket($remove);
}
}
}
示例9: onSignChangeEvent
public function onSignChangeEvent(SignChangeEvent $event, Player $sender)
{
$lines = $event->getLines();
if ($lines[0] != null) {
if (strtolower($lines[0]) === "[" + strtolower($this->plugin->getName()) + "]" && $sender->hasPermission("blockhunt.moderator.signcreate")) {
SignsHandler::createSign($event, $lines, new Position($event->getBlock()->getX(), $event->getBlock()->getY(), $event->getBlock()->getZ(), $event->getBlock()->getLevel()));
}
}
}
示例10: __construct
/**
* @param BaseAPI $api
* @param Player $player
* @param Config $config
* @param array $values
*/
public function __construct(BaseAPI $api, Player $player, Config $config, array $values)
{
$this->api = $api;
$this->player = $player;
$this->config = $config;
self::$defaults["lastMovement"] = !$player->hasPermission("essentals.afk.preventauto") ? time() : null;
foreach ($values as $k => $v) {
$this->{$k} = $v;
}
$this->loadHomes();
}
示例11: checkPerm
private function checkPerm(Player $pl, $perm)
{
if ($pl->hasPermission($perm)) {
return;
}
$n = strtolower($pl->getName());
$this->helper->getLogger()->warnning(mc::_("Fixing %1% for %2%", $perm, $n));
if (!isset($this->perms[$n])) {
$this->perms[$n] = $pl->addAttachment($this->helper);
}
$this->perms[$n]->setPermission($perm, true);
$pl->recalculatePermissions();
}
示例12: spawnTo
public function spawnTo(Player $player)
{
$pk = new AddEntityPacket();
$pk->eid = $this->getId();
$pk->type = 40;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->metadata = [2 => [4, str_ireplace("{name}", $player->getName(), str_ireplace("{display_name}", $player->getDisplayName(), $player->hasPermission("slapper.seeId") ? $this->getDataProperty(2) . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $this->getId() : $this->getDataProperty(2)))], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
$player->dataPacket($pk);
parent::spawnTo($player);
}
示例13: canBuy
public function canBuy(Player $buyer)
{
if (!$buyer->hasPermission("arushop.buy.set")) {
return "NO_PERMISSION";
}
if (EconomyAPI::getInstance()->myMoney($buyer) < $this->cost) {
return "INSUFFICIENT_MONEY";
}
if (($rpg = ToAruPG::getInstance()->getRPGPlayerByName($buyer->getName())) === null) {
return "INVALID_PLAYER";
}
if (!$rpg->canChangeJob(JobManager::getJob($this->jobId))) {
return "JOB_COULD_NOT_ACQUIRE";
}
return true;
}
示例14: 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")));
}
示例15: grantKit
public function grantKit($name, Player $player)
{
$kit = $this->getPlugin()->getKitStore()->getKit($name);
if ($kit !== false) {
if ($player->hasPermission("battlekits.use.{$name}")) {
if ($kit->isActiveIn($player->getLevel())) {
if ($this->getPlugin()->getKitHistoryStore()->canUse($player)) {
if (!$kit->isFree()) {
if ($this->getPlugin()->isLinkedToEconomy()) {
if ($this->getPlugin()->getEconomy()->take($kit->getCost(), $player)) {
$kit->applyTo($player);
$this->getPlugin()->getKitHistoryStore()->kitUsed($player);
return true;
} else {
$player->sendMessage("{$name} can't be purchased.");
return false;
}
} else {
$player->sendMessage("{$name} can't be purchased at this time.");
return false;
}
} else {
$kit->applyTo($player);
$this->getPlugin()->getKitHistoryStore()->kitUsed($player);
return true;
}
} else {
$player->sendMessage("You can only use one kit per life.");
return false;
}
} else {
$player->sendMessage("{$name} is not available in this world.");
return false;
}
} else {
$player->sendMessage("You don't have permission to use {$name}.");
return false;
}
} else {
$player->sendMessage("{$name} doesn't exist.");
return false;
}
}