本文整理汇总了PHP中pocketmine\event\player\PlayerInteractEvent::isCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerInteractEvent::isCancelled方法的具体用法?PHP PlayerInteractEvent::isCancelled怎么用?PHP PlayerInteractEvent::isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent::isCancelled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: crateKeys
public function crateKeys(PlayerInteractEvent $event)
{
$player = $event->getPlayer();
$block = $event->getBlock();
if ($block->getId() == $this->getConfig()->get("Crate") && !$event->isCancelled()) {
if ($player->getInventory()->getItemInHand()->getId() == $this->getConfig()->get("CrateKey-Item")) {
$prizes = array(Item::get(rand($this->getConfig()->get("ID-1"), $this->getConfig()->get("ID-2")), 0, $this->getConfig()->get("number-of-items")));
foreach ($prizes as $prize) {
$player->getInventory()->addItem($prize);
}
$player->sendMessage($this->getConfig()->get("completed"));
$player->getInventory()->removeItem(item::get($this->getConfig()->get("CrateKey-Item"), 0, 1));
$event->setCancelled(true);
} else {
$player->sendMessage($this->getConfig()->get("failed"));
$event->setCancelled(true);
}
} elseif (!$event->isCancelled()) {
$event->setCancelled(false);
}
}
示例3: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
if ($event->isCancelled()) {
return;
}
$player = $event->getPlayer();
$block = $event->getBlock();
$key = $player->getName();
if (isset($this->doubleTouchQueue[$key])) {
if (abs(time() - $this->doubleTouchQueue[$key]["time"]) < 2000) {
/** @var $lastBlock Block */
$lastBlock = $this->doubleTouchQueue[$key]["block"];
if ($block->getX() === $lastBlock->getX() and $block->getY() === $lastBlock->getY() and $block->getZ() === $lastBlock->getZ()) {
if ($this->chopTree($player, $block, $event->getItem(), self::TYPE_DOUBLE_TOUCH)) {
$event->setCancelled(true);
}
}
}
unset($this->doubleTouchQueue[$key]);
} else {
$this->doubleTouchQueue[$key] = ["time" => time(), "block" => $block];
}
}
示例4: onInteract
public function onInteract(PlayerInteractEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
if (isset($this->watchers[strtolower($ev->getPlayer()->getName())])) {
$ev->setCancelled();
}
}
示例5: onInteract
public function onInteract(PlayerInteractEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
$world = $pl->getLevel()->getName();
if (!isset($this->wcfg[$world])) {
return;
}
$item = $ev->getItem();
if (!isset($this->wcfg[$world][$item->getId()])) {
return;
}
$pl->sendMessage(mc::_("You can not use that item here!"));
$ev->setCancelled();
}
示例6: onTouch
public function onTouch(PlayerInteractEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
if (!$this->getState($pl, false)) {
return;
}
if ($ev->getBlock()->getId() == Block::AIR) {
return;
}
if (!$pl->isCreative() || !$this->creative) {
if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
//echo "Not using an PickAxe\n"; //##DEBUG
return;
}
}
$bl = $ev->getBlock();
if ($this->items && $this->itemwear) {
$hand = $pl->getInventory()->getItemInHand();
$bl->getLevel()->useBreakOn($bl, $hand, $pl);
$pl->getInventory()->setItemInHand($hand);
} else {
$bl->getLevel()->useBreakOn($bl, null, $pl);
}
}
示例7: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
if (!$event->isCancelled()) {
$this->checkArea($event);
}
}
示例8: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
if (!$event->isCancelled()) {
$this->protectBlock($event);
}
}
示例9: onPlayerInteract
/**
* @priority HIGHEST
*/
public function onPlayerInteract(PlayerInteractEvent $event)
{
if ($event->isCancelled()) {
return;
}
$p = $event->getPlayer();
$b = $event->getBlock();
if ($b->getID() !== 92 || $p->getHealth() >= $p->getMaxHealth()) {
return;
}
$this->getServer()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($p, 3, EntityRegainHealthEvent::CAUSE_EATING));
if (!$ev->isCancelled()) {
if (($dmg = $b->getDamage() + 1) >= 0x6) {
$b->getLevel()->setBlock($b, Block::get(0, 0));
} else {
$b->getLevel()->setBlock($b, Block::get(92, $dmg));
}
$p->heal($ev->getAmount(), $ev);
}
}