本文整理汇总了PHP中pocketmine\event\player\PlayerItemConsumeEvent::setCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerItemConsumeEvent::setCancelled方法的具体用法?PHP PlayerItemConsumeEvent::setCancelled怎么用?PHP PlayerItemConsumeEvent::setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerItemConsumeEvent
的用法示例。
在下文中一共展示了PlayerItemConsumeEvent::setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: playerItemConsume
public function playerItemConsume(PlayerItemConsumeEvent $event)
{
$player = $event->getPlayer();
if ($player->getGamemode() == 0) {
$item = $event->getItem();
$item_consumed = $item->getID();
if ($this->isExistsItem($item_consumed)) {
$event->setCancelled();
$count = $item->getCount();
if ($count == 1) {
$item = Item::get(0, 0, 0);
} else {
$item->setCount($count - 1);
}
$player->getInventory()->setItemInHand($item);
if ($item_consumed == 367 || $item_consumed == 365) {
if ($this->setPlayerPoisoned($player->getDisplayName(), $this->poison[$item_consumed]) == true) {
$this->chat($player, "You have been poisoned by food", 4);
}
}
$var = $this->items[$item_consumed];
$this->addFoodLevel($player, $var[0]);
$this->addFoodSaturationLevel($player, $var[1]);
$this->test($player->getDisplayName());
}
}
}
示例2: onDrop
public function onDrop(PlayerItemConsumeEvent $event)
{
if ($event->getItem() instanceof Arrow or $event->getItem() instanceof Snowball) {
if ($event->getItem()->shootingEntity == null) {
return;
}
if (isset($this->object_hash[spl_object_hash($event->getEntity())])) {
$event->setCancelled();
}
}
}
示例3: onPlayerEat
public function onPlayerEat(pic $ev)
{
$p = $ev->getPlayer();
$i = $ev->getItem();
switch ($this->phase) {
case 0:
//Waiting in the lobby
//Waiting in the lobby
case 1:
//Starting the game
$ev->setCancelled();
break;
case 2:
case 3:
if ($i->getId() == Item::GOLDEN_APPLE) {
$p->addEffect(Effect::getEffect(6)->setAmplifier(1)->setDuration(4));
}
break;
}
}
示例4: onConsume
public function onConsume(PlayerItemConsumeEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
if ($pl->hasPermission("wp.banitem.exempt")) {
return;
}
$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();
}
示例5: onConsume
public function onConsume(PlayerItemConsumeEvent $event)
{
$session = $this->main->getSession($event->getPlayer());
if (!$session instanceof Session) {
$event->setCancelled();
return;
}
if ($session->onConsume($event) === false) {
$event->setCancelled();
}
}
示例6: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
if (!$this->isValidPlayer($event->getPlayer())) {
return;
}
if ($this->players[$event->getPlayer()->getName()]->getSkillByItem($event->getItem()) !== null) {
$event->setCancelled();
}
}
示例7: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
$player = $event->getPlayer();
if (!$this->isLogin($player)) {
$event->setCancelled();
return true;
}
}
示例8: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
if (isset($this->needAuth[$event->getPlayer()->getName()])) {
$event->setCancelled();
$this->deauthenticatePlayer($event->getPlayer());
}
}
示例9: onItemConsume
public function onItemConsume(PlayerItemConsumeEvent $event)
{
if ($this->plugin->getConfig()->getAll()["block-all-events"]) {
if (!ServerAuth::getAPI()->isPlayerRegistered($event->getPlayer()->getName()) || !ServerAuth::getAPI()->isPlayerAuthenticated($event->getPlayer())) {
$event->setCancelled(true);
}
}
}
示例10: h_onItemConsume
public function h_onItemConsume(PlayerItemConsumeEvent $event)
{
if (!$this->isLoggedIn()) {
$event->setCancelled();
}
}
示例11: onEat
public function onEat(PlayerItemConsumeEvent $event)
{
$user = $this->main->getUserByPlayer($event->getPlayer());
if ($user === null or !$user->isPlaying()) {
$event->setCancelled();
}
}
示例12: onDrop
public function onDrop(PlayerItemConsumeEvent $event)
{
if ($event->getItem() instanceof Arrow) {
if ($event->getItem()->shootingEntity == null) {
return;
}
if ($event->getItem()->shootingEntity instanceof Entities) {
$event->setCancelled();
}
}
}
示例13: onPlayerItemConsume
public function onPlayerItemConsume(\pocketmine\event\player\PlayerItemConsumeEvent $event)
{
if (!$this->isLogin($event->getPlayer())) {
$event->setCancelled();
}
}
示例14: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
$event->setCancelled($this->isLogin($event->getPlayer()) ? false : true);
}
示例15: handleDataPacket
//.........这里部分代码省略.........
$this->level->setBlock($block, new Air());
break;
}
$this->lastBreak = microtime(true);
break;
case PlayerActionPacket::ACTION_ABORT_BREAK:
$this->lastBreak = PHP_INT_MAX;
break;
case PlayerActionPacket::ACTION_RELEASE_ITEM:
if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
$bow = $this->inventory->getItemInHand();
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
$this->inventory->sendContents($this);
break;
}
$arrow = false;
foreach ($this->inventory->getContents() as $item) {
if ($item->getId() == Item::ARROW) {
$arrow = $item;
}
}
if ($arrow === false and $this->isCreative()) {
$arrow = Item::get(Item::ARROW, 0, 1);
} elseif ($arrow === false) {
break;
}
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
$diff = $this->server->getTick() - $this->startAction;
$p = $diff / 20;
$f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
if ($f < 0.1 or $diff < 5) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$ev->getProjectile()->kill();
$this->inventory->sendContents($this);
} else {
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
if ($this->isSurvival()) {
$this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
$bow->setDamage($bow->getDamage() + 1);
if ($bow->getDamage() >= 385) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
} else {
$this->inventory->setItemInHand($bow);
}
}
if ($ev->getProjectile() instanceof Projectile) {
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
if ($projectileEv->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$ev->getProjectile()->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
} else {
$ev->getProjectile()->spawnToAll();
}
}
}
} elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
//Milk!
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));