本文整理汇总了PHP中pocketmine\event\player\PlayerDeathEvent::getEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerDeathEvent::getEntity方法的具体用法?PHP PlayerDeathEvent::getEntity怎么用?PHP PlayerDeathEvent::getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerDeathEvent
的用法示例。
在下文中一共展示了PlayerDeathEvent::getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPlayerDeath
/**
* @priority LOW
*/
public function onPlayerDeath(PlayerDeathEvent $e)
{
list($timer, $msg) = $this->getState($e->getEntity(), [0, ""]);
if (time() - $timer > 1) {
return;
}
$e->setDeathMessage($msg);
$this->unsetState($e->getEntity());
}
示例2: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$player = $event->getEntity();
if ($player instanceof Player) {
$name = $player->getName();
$level = $player->getLevel()->getName();
$disabledWorlds = $this->getConfig()->getNested("go-to-server-spawn-on-death");
foreach ($disabledWorlds as $disabledWorld) {
if ($disabledWorld === $level) {
return;
} else {
$this->temp->setNested("{$name}", $level);
$this->temp->save();
}
}
}
}
示例3: onDeath
public function onDeath(PlayerDeathEvent $event)
{
foreach ($this->tntRun->arenas as $arena) {
if ($arena->getPlayerManager()->isPlaying($event->getEntity())) {
$arena->getPlayerHandler()->leavePlayer($event->getEntity());
return;
}
}
}
示例4: onPlayerDeath
public function onPlayerDeath(PlayerDeathEvent $event)
{
$p = $event->getEntity();
$pos = $event->getEntity()->getPosition();
if ($pos->y <= 0) {
$pos->add(0, -$pos->y, 0);
}
$pos->add(0, 1, 0);
$p->setSpawn($pos);
}
示例5: onDeath
public function onDeath(PlayerDeathEvent $event)
{
if ($event->getEntity()->getLastDamageCause() instanceof EntityDamageByEntityEvent) {
$killer = $event->getEntity()->getLastDamageCause()->getDamager();
if ($killer instanceof Player) {
$this->plugin->updatePlayer($event->getEntity(), "deaths");
$this->plugin->updatePlayer($killer, "kills");
}
}
}
示例6: PlayerDeathEvent
/**
* @param PlayerDeathEvent $event
*
* @priority LOWEST
* @ignoreCancelled true
*/
public function PlayerDeathEvent(PlayerDeathEvent $event)
{
if (isset($this->players[$event->getEntity()->getName()])) {
unset($this->players[$event->getEntity()->getName()]);
if (isset($this->tasks[$event->getEntity()->getName()])) {
$this->getServer()->getScheduler()->cancelTask($this->tasks[$event->getEntity()->getName()]);
}
unset($this->tasks[$event->getEntity()->getName()]);
}
}
示例7: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$event->setDrops([]);
if (isset($this->attackQueue[$event->getEntity()->getName()])) {
$damager = $this->getServer()->getPlayerExact($this->attackQueue[$event->getEntity()->getName()]);
if (!$damager instanceof Player) {
return;
}
$amount = $this->db["payback"];
$this->economyAPI->addMoney($damager, $amount);
$message = str_replace("%money%", $amount, $this->get("pvpmoney-paid"));
$this->message($damager, $message);
unset($this->attackQueue[$event->getEntity()->getName()]);
}
}
示例8: onPlayerDeathEvent
public function onPlayerDeathEvent(PlayerDeathEvent $event)
{
$cfg = $this->getConfig();
$duration = $cfg->get("Duration");
$particles = $cfg->get("Particles");
$amplifier = $cfg->get("Amplifier");
$give = $cfg->get("Add-Money");
$lose = $cfg->get("Lost-Money");
$id = $cfg->get("Effect-ID");
$effect = Effect::getEffect($id);
$effect->setVisible($particles);
$effect->setAmplifier($amplifier);
$effect->setDuration($duration);
$player = $event->getEntity();
$name = strtolower($player->getName());
if ($player instanceof Player) {
$cause = $player->getLastDamageCause();
if ($cause instanceof EntityDamageByEntityEvent) {
$damager = $cause->getDamager();
if ($damager instanceof Player) {
$damager->sendMessage("You killed " . $player . ".\nYou earn \$" . $give . " for getting a kill and an effect!");
$damager->addEffect($effect);
$this->money->addMoney($damager, $give);
$player->sendMessage("You were killed by " . $damager);
$this->money->reduceMoney($player, $lose);
}
}
}
}
示例9: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$cause = $event->getEntity()->getLastDamageCause();
if ($cause instanceof EntityDamageByEntityEvent) {
$player = $event->getEntity();
$killer = $event->getEntity()->getLastDamageCause()->getDamager();
$fizz = new FizzSound($killer);
$bat = new BatSound($player);
$player->sendMessage(TextFormat::RED . $killer->getName() . TextFormat::GOLD . " Killed you with " . TextFormat::LIGHT_PURPLE . $killer->getHealth() . TextFormat::RED . " hearts left and while using " . TextFormat::BLUE . $killer->getInventory()->getItemInHand() . "!");
$player->getLevel()->addSound($bat);
if ($killer instanceof Player) {
$killer->sendMessage(TextFormat::GREEN . "You Killed " . $player->getName() . "!");
$killer->getLevel()->addSound($fizz);
}
}
}
示例10: onPlayerDeath
public function onPlayerDeath(PlayerDeathEvent $e)
{
$pl = $e->getEntity();
if (!$pl instanceof Player) {
return;
}
if (!$pl->hasPermission("gb.cdeath")) {
return;
}
$keepinv = $this->keepinv;
if ($keepinv == "perms") {
foreach (["keep", "nodrops", "default"] as $m) {
if ($pl->hasPermission("gb.keepinv." . $m)) {
break;
}
}
}
switch ($keepinv) {
case "keep":
$e->setKeepInventory(true);
$e->setDrops([]);
break;
case "nodrops":
$e->setKeepInventory(false);
$e->setDrops([]);
break;
}
}
示例11: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$player = $event->getEntity();
if (Main::isActive($player)) {
Main::removeActive($player);
}
}
示例12: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$player = $event->getEntity();
if ($this->plugin->isActive($player)) {
$this->plugin->removeActive($player);
}
}
示例13: onPlayerDeathEvent
public function onPlayerDeathEvent(PlayerDeathEvent $event)
{
if ($event->getEntity() instanceof Player) {
$player = $event->getEntity();
$name = $event->getEntity()->getName();
if ($this->allEnabled == "true") {
$event->setKeepInventory(true);
$player->sendMessage(TextFormat::YELLOW . "Your inventory has been saved");
} else {
if (in_array($name, $this->playersEnabled)) {
$event->setKeepInventory(true);
$player->sendMessage(TextFormat::YELLOW . "Your inventory has been saved");
}
}
}
}
示例14: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$cfg = $this->getConfig();
$enable = $cfg->get("enable");
if ($event->getEntity() instanceof Player and $enable !== true) {
$event->setDrops([]);
}
}
示例15: onDeath
public function onDeath(PlayerDeathEvent $event)
{
$this->plugin->players = $this->plugin->players - 1;
$d = $this->plugin->points->get($event->getEntity()->getName());
$d["deaths"] = $d["deaths"] + 1;
$killer = $event->getEntity()->getLastDamageCause()->getCause()->getDamager();
if ($killer instanceof Player) {
$k = $this->plugin->points->get($killer->getName());
$k["kills"] = $k["kills"] + 1;
}
$event->getEntity()->kick("Death");
$event->setDeathMessage("[HG] " . $event->getEntity()->getName() . " died!\nThere are " . $this->plugin->players . " left.");
if ($this->plugin->players <= 1) {
$this->plugin->getServer()->broadcastMessage("[HG] Game ended!");
$this->plugin->getServer()->shutdown();
}
}