本文整理汇总了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());
}
示例2: onDeath
public function onDeath(PlayerDeathEvent $event)
{
if (!$this->killedByBlock) {
return;
}
$this->killedByBlock = false;
$event->setDeathMessage(null);
$this->getServer()->broadcastMessage($this->getCustomMessage($event->getEntity()));
}
示例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);
}
示例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();
}
}
示例5: h_onDeath
public function h_onDeath(PlayerDeathEvent $event)
{
$event->setDrops([]);
$event->setDeathMessage("");
$event->setKeepInventory(false);
}
示例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
}
}
}
}
示例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("");
}
}
示例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("");
}
}
}
示例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!");
}
}
}
}
}
}
}
示例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();
}
}
}
示例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());
}
}
示例13: onPlayerDeath
public function onPlayerDeath(PlayerDeathEvent $event)
{
$event->setDeathMessage("/♣ [" . ($this->isKorean() ? "사망" : "Died") . "] " . $event->getEntity()->getName());
}