本文整理汇总了PHP中pocketmine\event\player\PlayerInteractEvent::setCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerInteractEvent::setCancelled方法的具体用法?PHP PlayerInteractEvent::setCancelled怎么用?PHP PlayerInteractEvent::setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent::setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPlayerInteract
/**
* @param PlayerInteractEvent $event
*
* @priority HIGHEST
*/
public function onPlayerInteract(PlayerInteractEvent $event)
{
echo __METHOD__ . "," . __LINE__ . "\n";
//##DEBUG
if (!$this->auth->isPlayerAuthenticated($event->getPlayer())) {
echo __METHOD__ . "," . __LINE__ . "\n";
//##DEBUG
$event->setCancelled(true);
}
}
示例2: onBlockTouch
public function onBlockTouch(PlayerInteractEvent $event)
{
$player = $event->getPlayer();
if (!$player->haspermission("worldprotetor.block.break")) {
$event->setCancelled(true);
} else {
$event->setCancelled(false);
}
}
示例3: compassTracker
public function compassTracker(PlayerInteractEvent $ev)
{
$p = $ev->getPlayer();
if ($p->getInventory()->getItemInHand()->getId() === 345 && $ev->getAction() === PlayerInteractEvent::RIGHT_CLICK_AIR) {
if (in_array($ev->getPlayer()->getName(), $this->compass)) {
$p->sendMessage("§c§lYou cant use this for 3 minutes!");
$ev->setCancelled(true);
return;
}
if (!in_array($ev->getPlayer()->getName(), $this->compass)) {
array_push($this->compass, $ev->getPlayer()->getName());
$p->sendTip("§c§lYou cant use this for 3 minutes!");
$task = new Task($this, $ev->getPlayer());
$this->getServer()->getScheduler()->scheduleDelayedTask($task, 3600);
$pickqv = [];
$distSqMap = [];
foreach ($p->getLevel()->getPlayers() as $player) {
asort($distSqMap);
}
foreach ($distSqMap as $id => $distSq) {
$p->sendMessage("§b§l" . $picked[$id]->getDisplayName() . " §fis §c" . round(sqrt($distSq)) . " §fblocks from you.");
}
}
}
}
示例4: onInteract
public function onInteract(PlayerInteractEvent $event)
{
if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === 0) {
$event->setCancelled(true);
} elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
$event->setCancelled(true);
}
}
示例5: onInteract
public function onInteract(PlayerInteractEvent $event)
{
if ($event->getPlayer()->hasPermission("worldprotector.block.interact")) {
$event->setCancelled(false);
} else {
$event->setCancelled(true);
}
}
示例6: onChestOpen
public function onChestOpen(PlayerInteractEvent $event)
{
if ($event->getBlock()->getID() == Main::ITEM_ID) {
$chest = $event->getPlayer()->getLevel()->getTile($event->getBlock());
if ($chest instanceof Chest) {
//Check Command status
//0
if ($this->plugin->getCommandStatus($event->getPlayer()->getName()) == 0) {
//Check bypass permission
if ($event->getPlayer()->hasPermission("chestlocker.bypass") == false) {
//Check if Chest is registered
if ($this->plugin->isChestRegistered($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ())) {
if ($this->plugin->getChestOwner($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ()) != strtolower($event->getPlayer()->getName())) {
$event->setCancelled(true);
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&4You aren't the owner of this " . Main::ITEM_NAME_2 . "."));
}
}
}
}
//1
if ($this->plugin->getCommandStatus($event->getPlayer()->getName()) == 1) {
//Check if Chest is registered
if ($this->plugin->isChestRegistered($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ())) {
if ($this->plugin->getChestOwner($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ()) != strtolower($event->getPlayer()->getName())) {
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&4You aren't the owner of this " . Main::ITEM_NAME_2 . "."));
} else {
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " already locked"));
}
} else {
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " locked"));
$this->plugin->lockChest($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ(), $event->getPlayer()->getName());
}
$event->setCancelled(true);
$this->plugin->setCommandStatus(0, $event->getPlayer()->getName());
}
//2
if ($this->plugin->getCommandStatus($event->getPlayer()->getName()) == 2) {
//Check if Chest is registered
if ($this->plugin->isChestRegistered($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ())) {
if ($this->plugin->getChestOwner($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ()) != strtolower($event->getPlayer()->getName())) {
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&4You aren't the owner of this " . Main::ITEM_NAME_2 . "."));
} else {
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " unlocked"));
$this->plugin->unlockChest($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ(), $event->getPlayer()->getName());
}
} else {
$event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " not registered"));
}
$event->setCancelled(true);
$this->plugin->setCommandStatus(0, $event->getPlayer()->getName());
}
}
}
}
示例7: onPlayerInteract
/**
* @priority HIGHEST
*/
public function onPlayerInteract(PlayerInteractEvent $event)
{
if ($event->isCancelled()) {
return;
}
$p = $event->getPlayer();
$b = $event->getBlock();
if ($b->getID() !== 26) {
return;
}
$event->setCancelled();
$xTabel = [3 => 1, 1 => -1];
$b = $b->getSide(5, isset($xTabel[$dmg = $b->getDamage()]) ? $xTabel[$dmg] : 0);
$zTabel = [0 => 1, 2 => -1];
$b = $b->getSide(3, isset($zTabel[$dmg]) ? $zTabel[$dmg] : 0);
$this->getServer()->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($p, $b));
if ($ev->isCancelled()) {
return;
}
$property = (new \ReflectionClass("\\pocketmine\\Player"))->getProperty("sleeping");
$property->setAccessible(true);
foreach ($p->getLevel()->getNearbyEntities($p->getBoundingBox()->grow(2, 1, 2), $p) as $pl) {
if ($pl instanceof Player && $pl->isSleeping()) {
if ($b->distance($property->getValue($pl)) <= 0.1) {
$p->sendMessage("This bed is occupied");
return;
}
}
}
$property->setValue($p, $b);
$p->teleport($b->add(0.5, 0.5, 0.5));
$p->sendMetadata($p->getViewers());
$p->sendMetadata($p);
}
示例8: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
$p = $event->getPlayer();
$i = $event->getItem();
if ($i->getID() !== 339 || ($money = $i->getDamage()) < 1) {
return;
}
$m = "[Check] ";
$ik = $this->isKorean();
if (!isset($this->touch[$n = $p->getName()])) {
$this->touch[$n] = 0;
}
$c = microtime(true) - $this->touch[$n];
if ($c > 0) {
$m .= $ik ? "수표를 사용하시려면 다시한번눌러주세요. \n 수표 정보 : " . $money . "\$" : "If you want to use this check, One more touch block \n Check Info : " . $money . "\$";
} else {
$i->setCount($i->getCount() - 1);
$p->getInventory()->setItem($p->getInventory()->getHeldItemSlot(), $i);
$this->giveMoney($p, $money);
$m .= $ik ? "수표를 사용하셨습니다.\n 수표 정보 : " . $money . "\$" : "You use the check. \n Check Info : " . $money . "\$";
}
$this->touch[$n] = microtime(true) + 1;
if (isset($m)) {
$p->sendMessage($m);
}
$event->setCancelled();
}
示例9: onTouch
public function onTouch(PlayerInteractEvent $event)
{
$player = $event->getPlayer();
$block = $event->getBlock();
if ($this->plugin->war->getSoldier($player) != null) {
if ($block->getId() == 54) {
$event->setCancelled();
$block = $event->getBlock();
if (!isset($this->touchinfo[$player->getName()])) {
$this->giveRandomItem($player);
$this->touchinfo[$player->getName()] = [];
array_push($this->touchinfo[$player->getName()], "{$block->getX()}.{$block->getY()}.{$block->getZ()}");
$this->plugin->message($player, $this->plugin->get("get-item-from-chest"));
} else {
foreach ($this->touchinfo[$player->getName()] as $stringpos) {
if ($stringpos == "{$block->getX()}.{$block->getY()}.{$block->getZ()}") {
$this->plugin->alert($player, $this->plugin->get("already-get-item"));
return true;
}
}
$this->giveRandomItem($player);
array_push($this->touchinfo[$player->getName()], "{$block->getX()}.{$block->getY()}.{$block->getZ()}");
$this->plugin->message($player, $this->plugin->get("get-item-from-chest"));
}
}
}
}
示例10: onBlockTap
/**
* @param PlayerInteractEvent $event
*
* @priority HIGH
*/
public function onBlockTap(PlayerInteractEvent $event)
{
// PowerTool
if ($this->getAPI()->executePowerTool($event->getPlayer(), $event->getItem())) {
$event->setCancelled(true);
}
}
示例11: onInteract
public function onInteract(PlayerInteractEvent $event)
{
$player = $event->getPlayer();
if ($event->getBlock()->getId() === FlowerPotMain::BLOCK_ITEM_FRAME and !$player->isOp()) {
$player->sendMessage("You do not have permission.");
$event->setCancelled();
}
}
示例12: onTouch
public function onTouch(PlayerInteractEvent $event)
{
$block = $event->getBlock();
if (isset($this->configData["{$block->x}:{$block->y}:{$block->z}"])) {
$this->getServer()->getCommandMap()->dispatch($event->getPlayer(), $this->configData["{$block->x}:{$block->y}:{$block->z}"]);
$event->setCancelled();
}
}
示例13: onPlayerInteract
/**
* When the player move while
* he is not logged in, cancel
* the event
* @param PlayerInteractEvent $event
*/
public function onPlayerInteract(PlayerInteractEvent $event)
{
$player = $event->getPlayer();
if (!User::exist($player->getName()) || User::exist($player->getName()) && !User::get($player->getName())->isLogged()) {
$event->setCancelled(true);
$player->sendMessage($this->needLogin);
}
}
示例14: onTouchCrate
public function onTouchCrate(PlayerInteractEvent $e)
{
if ($e->getBlock()->getId() == 54) {
if ($e->getItem()->getId() == $this->getConfig()->get("cratekey-item")) {
if ($e->getPlayer()->hasPermission("mysterycrates.crates.open")) {
$e->setCancelled();
$this->openCrate($e->getPlayer());
}
}
}
}
示例15: onInteract
public function onInteract(PlayerInteractEvent $event)
{
if (!$event->getPlayer()->hasPermission("customareas.bypass")) {
foreach ($this->plugin->areas as $area) {
if ($area->isInside($event->getBlock()) and !$area->canBuild($event->getPlayer())) {
$event->setCancelled();
$event->getPlayer()->sendMessage("This is " . $area->owner . "'s private area");
}
}
}
}