当前位置: 首页>>代码示例>>PHP>>正文


PHP PlayerDeathEvent::setKeepExperience方法代码示例

本文整理汇总了PHP中pocketmine\event\player\PlayerDeathEvent::setKeepExperience方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerDeathEvent::setKeepExperience方法的具体用法?PHP PlayerDeathEvent::setKeepExperience怎么用?PHP PlayerDeathEvent::setKeepExperience使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\player\PlayerDeathEvent的用法示例。


在下文中一共展示了PlayerDeathEvent::setKeepExperience方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onDeath

 public function onDeath(PlayerDeathEvent $event)
 {
     $event->setKeepInventory($this->keepInventory);
     $event->setKeepExperience($this->keepExperience);
 }
开发者ID:ClearSkyTeam,项目名称:Plugins,代码行数:5,代码来源:MainClass.php

示例2: kill


//.........这里部分代码省略.........
                     $params[] = $e->getDisplayName();
                 } elseif ($e instanceof Living) {
                     $message = "death.attack.arrow";
                     $params[] = $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName();
                     break;
                 } else {
                     $params[] = "Unknown";
                 }
             }
             break;
         case EntityDamageEvent::CAUSE_SUICIDE:
             $message = "death.attack.generic";
             break;
         case EntityDamageEvent::CAUSE_VOID:
             $message = "death.attack.outOfWorld";
             break;
         case EntityDamageEvent::CAUSE_FALL:
             if ($cause instanceof EntityDamageEvent) {
                 if ($cause->getFinalDamage() > 2) {
                     $message = "death.fell.accident.generic";
                     break;
                 }
             }
             $message = "death.attack.fall";
             break;
         case EntityDamageEvent::CAUSE_SUFFOCATION:
             $message = "death.attack.inWall";
             break;
         case EntityDamageEvent::CAUSE_LAVA:
             $message = "death.attack.lava";
             break;
         case EntityDamageEvent::CAUSE_FIRE:
             $message = "death.attack.onFire";
             break;
         case EntityDamageEvent::CAUSE_FIRE_TICK:
             $message = "death.attack.inFire";
             break;
         case EntityDamageEvent::CAUSE_DROWNING:
             $message = "death.attack.drown";
             break;
         case EntityDamageEvent::CAUSE_CONTACT:
             if ($cause instanceof EntityDamageByBlockEvent) {
                 if ($cause->getDamager()->getId() === Block::CACTUS) {
                     $message = "death.attack.cactus";
                 }
             }
             break;
         case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
         case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
             if ($cause instanceof EntityDamageByEntityEvent) {
                 $e = $cause->getDamager();
                 if ($e instanceof Player) {
                     $message = "death.attack.explosion.player";
                     $params[] = $e->getDisplayName();
                 } elseif ($e instanceof Living) {
                     $message = "death.attack.explosion.player";
                     $params[] = $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName();
                     break;
                 }
             } else {
                 $message = "death.attack.explosion";
             }
             break;
         case EntityDamageEvent::CAUSE_MAGIC:
             $message = "death.attack.magic";
             break;
         case EntityDamageEvent::CAUSE_CUSTOM:
             break;
         default:
     }
     Entity::kill();
     $ev = new PlayerDeathEvent($this, $this->getDrops(), new TranslationContainer($message, $params));
     $ev->setKeepInventory($this->server->keepInventory);
     $ev->setKeepExperience($this->server->keepExperience);
     $this->server->getPluginManager()->callEvent($ev);
     if (!$ev->getKeepInventory()) {
         foreach ($ev->getDrops() as $item) {
             $this->level->dropItem($this, $item);
         }
         if ($this->inventory !== null) {
             $this->inventory->clearAll();
         }
     }
     if ($this->server->expEnabled and !$ev->getKeepExperience()) {
         $exp = min(91, $this->getTotalXp());
         //Max 7 levels of exp dropped
         $this->getLevel()->spawnXPOrb($this->add(0, 0.2, 0), $exp);
         $this->setTotalXp(0, true);
     }
     if ($ev->getDeathMessage() != "") {
         $this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS);
     }
     $pos = $this->getSpawn();
     $this->setHealth(0);
     $pk = new RespawnPacket();
     $pk->x = $pos->x;
     $pk->y = $pos->y;
     $pk->z = $pos->z;
     $this->dataPacket($pk);
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:101,代码来源:Player.php


注:本文中的pocketmine\event\player\PlayerDeathEvent::setKeepExperience方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。