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


PHP PlayerDeathEvent::setDeathMessage方法代码示例

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


在下文中一共展示了PlayerDeathEvent::setDeathMessage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:12,代码来源:CmdSlay.php

示例2: onDeath

 public function onDeath(PlayerDeathEvent $event)
 {
     if (!$this->killedByBlock) {
         return;
     }
     $this->killedByBlock = false;
     $event->setDeathMessage(null);
     $this->getServer()->broadcastMessage($this->getCustomMessage($event->getEntity()));
 }
开发者ID:Redsnow132,项目名称:KillBlock,代码行数:9,代码来源:KillBlock.php

示例3: onPlayerDeathEvent

 public function onPlayerDeathEvent(PlayerDeathEvent $event)
 {
     $message = $event->getDeathMessage();
     if ($message instanceof TranslationContainer) {
         $message = $this->getServer()->getLanguage()->translateString($message->getText(), $message->getParameters());
     }
     AnnounceSystem::getInstance()->pushBroadCastPopup($message, 2);
     $event->setDeathMessage(null);
 }
开发者ID:organization,项目名称:AnnounceClear,代码行数:9,代码来源:AnnounceClear.php

示例4: 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();
     }
 }
开发者ID:linuzo,项目名称:SimpleHungerGames,代码行数:17,代码来源:EventHandler.php

示例5: h_onDeath

 public function h_onDeath(PlayerDeathEvent $event)
 {
     $event->setDrops([]);
     $event->setDeathMessage("");
     $event->setKeepInventory(false);
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:6,代码来源:SessionInterface.php

示例6: onDeath

 public function onDeath(PlayerDeathEvent $event)
 {
     if ($event->getEntity()->getLevel()->getName() == $this->getConfig()->get('aworld')) {
         //if in skywars aworld
         $this->aplayers = $this->aplayers - 1;
         //remove a player
         $victim = $event->getEntity()->getName();
         $this->addDeath($victim);
         $cause = $event->getEntity()->getLastDamageCause();
         if ($cause instanceof EntityDamageByEntityEvent) {
             $killer = $cause->getDamager();
             if ($killer instanceof Player) {
                 $this->addKill($killer->getName());
                 $event->setDeathMessage($victim . "[" . $this->getConfig()->get($victim[2]) . "] was killed by " . $killer->getName() . "[" . $this->getConfig()->get($killer->getName()[2]) . "]. " . $this->getConfig()->get('aworld'['neededplayers']) - $this->aplayers . " players remaining");
             }
         } else {
             $event->setDeathMessage($victim . "[" . $this->getConfig()->get($victim[2]) . "] died.");
         }
         if ($this->aplayers <= 1) {
             //if only 1 player is left
             foreach ($this->getServer()->getLevelByName($this->getConfig()->get('aworld'))->getPlayers() as $p) {
                 //detects the winner
                 if ($p->getGameMode() == 0) {
                     $p->sendMessage("You won the match!");
                     $p->sendMessage("The game has finished, you will be teleported to the lobby.");
                     $p->teleport($this->getServer()->getLevelByName($this->getConfig()->get('lobby'))->getSafeSpawn());
                     //teleport to the lobby
                     $points = $this->points->get($p)[2] + $this->config->get('points-per-match');
                     //get points and add
                     $deaths = $this->points->get($player)[0];
                     //get the victim's deaths, add one and store in a variable
                     $kills = $this->points->get($player)[1];
                     //get the players kills and store in a var
                     $this->config->set($p, array($deaths, $kills, $points));
                 } else {
                     $p->sendMessage("The match hs finished, thanks for watching.");
                     $p->teleport($this->getServer()->getLevelByName($this->config->get('lobby'))->getSafeSpawn());
                     $p->setGameMode(0);
                 }
                 $this->stopGame($this->config->get('aworld'));
                 //stop the game
             }
         }
     }
 }
开发者ID:EmreTr1,项目名称:SkyWarsForPE,代码行数:45,代码来源:Main.php

示例7: onDeath

 public function onDeath(PlayerDeathEvent $event)
 {
     $player = $event->getEntity();
     if (isset(FlameThrower::$tasks[$player->getName()])) {
         FlameThrower::$tasks[$player->getName()]->getHandler()->cancel();
     }
     if ($this->status === self::STAT_GAME_IN_PROGRESS) {
         $items = $event->getDrops();
         foreach ($items as $key => $item) {
             if ($item->getId() !== self::GUN_ID) {
                 unset($items[$key]);
             }
         }
         $event->setDrops($items);
         $cause = $player->getLastDamageCause();
         if ($cause !== null && $cause->getCause() == EntityDamageEvent::CAUSE_FALL) {
             if ($this->players[$player->getName()][2] === self::TEAM_BLUE) {
                 $playerColor = TextFormat::BLUE;
                 $damagerColor = TextFormat::RED;
                 $this->score[self::TEAM_RED]++;
             } else {
                 $playerColor = TextFormat::RED;
                 $damagerColor = TextFormat::BLUE;
                 $this->score[self::TEAM_BLUE]++;
             }
             $firstKill = "";
             if ($this->score[self::TEAM_BLUE] + $this->score[self::TEAM_RED] <= 1) {
                 $firstKill = TextFormat::YELLOW . "FIRST BLOOD\n" . TextFormat::WHITE;
             }
             $this->broadcastPopup($firstKill . $playerColor . $player->getName() . $damagerColor . " SUICIDED");
         }
         if (!$cause instanceof EntityDamageByEntityEvent) {
             return;
         }
         if ($cause !== null and $cause->getCause() === 15) {
             $damager = $cause->getDamager();
             if ($damager instanceof Player) {
                 if ($this->players[$damager->getName()][2] === self::TEAM_BLUE) {
                     $damagerColor = TextFormat::BLUE;
                     $playerColor = TextFormat::RED;
                     $this->score[self::TEAM_BLUE]++;
                 } else {
                     $damagerColor = TextFormat::RED;
                     $playerColor = TextFormat::BLUE;
                     $this->score[self::TEAM_RED]++;
                 }
                 $firstKill = "";
                 if ($this->score[self::TEAM_BLUE] + $this->score[self::TEAM_RED] <= 1) {
                     $firstKill = TextFormat::YELLOW . "FIRST BLOOD\n" . TextFormat::WHITE;
                 }
                 $this->broadcastPopup($firstKill . $damagerColor . $damager->getName() . TextFormat::WHITE . " -> " . $playerColor . $player->getName());
                 ++$this->killDeath[0][$damager->getName()];
                 ++$this->killDeath[1][$player->getName()];
                 $this->level[$damager->getName()] += $damager->getHealth() * 5;
                 $level = floor($this->level[$damager->getName()] / 10000);
                 $damager->setNameTag("Lv." . $level . $damagerColor . $damager->getName());
             }
         } elseif ($cause !== null and $cause->getCause() === 16) {
             $damager = $cause->getDamager();
             if ($damager instanceof Player) {
                 if ($this->players[$damager->getName()][2] === self::TEAM_BLUE) {
                     $damagerColor = TextFormat::BLUE;
                     $playerColor = TextFormat::RED;
                     $this->score[self::TEAM_BLUE]++;
                 } else {
                     $damagerColor = TextFormat::RED;
                     $playerColor = TextFormat::BLUE;
                     $this->score[self::TEAM_RED]++;
                 }
                 $firstKill = "";
                 if ($this->score[self::TEAM_BLUE] + $this->score[self::TEAM_RED] <= 1) {
                     $firstKill = TextFormat::YELLOW . "FIRST BLOOD\n" . TextFormat::WHITE;
                 }
                 $this->broadcastPopup($firstKill . $damagerColor . $damager->getName() . TextFormat::WHITE . " -O-> " . $playerColor . $player->getName());
                 ++$this->killDeath[0][$damager->getName()];
                 ++$this->killDeath[1][$player->getName()];
                 $this->level[$damager->getName()] += $damager->getHealth() * 5;
                 $level = floor($this->level[$damager->getName()] / 10000);
                 $damager->setNameTag("Lv." . $level . $damagerColor . $damager->getName());
             }
         }
         $event->setDeathMessage("");
     }
 }
开发者ID:EmreTr1,项目名称:MineCombat,代码行数:84,代码来源:MineCombat.php

示例8: onDeath

 public function onDeath(PlayerDeathEvent $e)
 {
     $msg = $this->getConfig()->get("death-message");
     $msg = str_replace("{PLAYER}", $e->getEntity()->getName(), $msg);
     $msg = str_replace("{BLOCK}", strtolower($this->getConfig()->get('damage-block-name')), $msg);
     if ($this->killedByBlock) {
         if ($this->getConfig()->get("broadcast-on-chat") === false) {
             foreach ($this->getServer()->getOnlinePlayers() as $allP) {
                 $allP->sendPopup('/n');
                 $allP->sendPopup($msg);
                 unset($this->killedByBlock);
                 $e->setDeathMessage(null);
             }
         } else {
             $e->setDeathMessage($msg);
             unset($this->killedByBlock);
         }
     } else {
     }
 }
开发者ID:GoneTone,项目名称:Chinese-Traditional-Translations-For-PocketMine-MP-Plugins,代码行数:20,代码来源:Main.php

示例9: onPlayerDeath

 public function onPlayerDeath(PlayerDeathEvent $event)
 {
     $this->plugin->log("GameLevelListener: onPlayerDeath " . $event->getEventName());
     if ($event->getEntity() instanceof Player) {
         if ($this->plugin->gameLevelManager->handlePlayerDeath($event->getEntity())) {
             $event->setDeathMessage("");
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:9,代码来源:GameLevelListener.php

示例10: onDeath

 public function onDeath(PlayerDeathEvent $event)
 {
     $player = $event->getEntity();
     if ($player instanceof Player) {
         if ($this->inArena($player)) {
             $event->setDeathMessage("");
             $arena = $this->getArena($player);
             $cause = $player->getLastDamageCause();
             $players = $this->getPlayers($arena);
             if ($cause instanceof EntityDamageByEntityEvent) {
                 $killer = $cause->getDamager();
                 $event->setDrops(array());
                 if ($killer instanceof Player) {
                     foreach ($players as $pn) {
                         $p = $this->getServer()->getPlayerExact($pn);
                         if ($p != null) {
                             $p->sendMessage($this->prefix . $killer->getNameTag() . TextFormat::GRAY . " hat " . $player->getNameTag() . TextFormat::GRAY . " getötet!");
                         }
                     }
                 } else {
                     foreach ($players as $pn) {
                         $p = $this->getServer()->getPlayerExact($pn);
                         if ($p != null) {
                             $p->sendMessage($this->prefix . $player->getNameTag() . TextFormat::GRAY . " ist gestorben!");
                         }
                     }
                 }
             } else {
                 $event->setDrops(array());
                 foreach ($players as $pn) {
                     $p = $this->getServer()->getPlayerExact($pn);
                     if ($p != null) {
                         if ($this->lasthit[$player->getName()] != "no") {
                             $p2 = $this->getServer()->getPlayerExact($this->lasthit[$player->getName()]);
                             if ($p2 != null) {
                                 $p->sendMessage($this->prefix . $p2->getNameTag() . TextFormat::WHITE . " hat " . $player->getNameTag() . TextFormat::WHITE . " getötet!");
                                 $this->lasthit[$player->getName()] = "no";
                             } else {
                                 $p->sendMessage($this->prefix . $player->getNameTag() . TextFormat::GRAY . " ist gestorben!");
                             }
                         } else {
                             $p->sendMessage($this->prefix . $player->getNameTag() . TextFormat::GRAY . " ist gestorben!");
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Bluplayz,项目名称:BedwarsPE,代码行数:49,代码来源:Bedwars.php

示例11: onDeath

 public function onDeath(PlayerDeathEvent $e)
 {
     $p = $e->getEntity();
     if ($p instanceof Player) {
         if ($this->getPlayerMode($p) === 0 || $this->getPlayerMode($p) === 2) {
             $e->setDeathMessage("");
         }
         if ($this->getPlayerMode($p) === 1) {
             $this->plugin->getServer()->getPluginManager()->callEvent($event = new PlayerLoseArenaEvent($this->plugin, $p, $this));
             $e->setDeathMessage("");
             $e->setDrops([]);
             $ingame = array_merge($this->lobbyp, $this->ingamep, $this->spec);
             $this->checkWinners($p);
             unset($this->ingamep[strtolower($p->getName())]);
             $this->spec[strtolower($p->getName())] = $p;
             foreach ($ingame as $pl) {
                 $pl->sendMessage($this->plugin->getPrefix() . str_replace(['%2', '%1'], [count($this->ingamep), $p->getName()], $this->plugin->getMsg('death')));
             }
             $this->checkAlive();
         }
     }
 }
开发者ID:Creeperface01,项目名称:ColorMatch,代码行数:22,代码来源:Arena.php

示例12: onPlayerDeath

 /**
  * @param PlayerDeathEvent $event
  *
  * @priority HIGHEST
  */
 public function onPlayerDeath(PlayerDeathEvent $event)
 {
     $player = $event->getEntity();
     CustomAlerts::getAPI()->setDeathMessage($event->getDeathMessage());
     if ($player instanceof Player) {
         $cause = $player->getLastDamageCause();
         if (CustomAlerts::getAPI()->isDeathHidden($cause)) {
             CustomAlerts::getAPI()->setDeathMessage("");
         } else {
             //Check if Death message is custom
             if (CustomAlerts::getAPI()->isDeathCustom($cause)) {
                 CustomAlerts::getAPI()->setDeathMessage(CustomAlerts::getAPI()->getDefaultDeathMessage($player, $cause));
             }
         }
         //Death Event
         $this->plugin->getServer()->getPluginManager()->callEvent(new CustomAlertsDeathEvent($player, $cause));
         $event->setDeathMessage(CustomAlerts::getAPI()->getDeathMessage());
     }
 }
开发者ID:xHFx,项目名称:CustomAlerts,代码行数:24,代码来源:EventListener.php

示例13: onPlayerDeath

 public function onPlayerDeath(PlayerDeathEvent $event)
 {
     $event->setDeathMessage("/♣ [" . ($this->isKorean() ? "사망" : "Died") . "]  " . $event->getEntity()->getName());
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:4,代码来源:MineFarm.php


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