diff --git a/src/event/player/PlayerDeathEvent.php b/src/event/player/PlayerDeathEvent.php index 132411c58..58a07fb1b 100644 --- a/src/event/player/PlayerDeathEvent.php +++ b/src/event/player/PlayerDeathEvent.php @@ -39,6 +39,7 @@ class PlayerDeathEvent extends EntityDeathEvent{ protected $player; private Translatable|string $deathMessage; + private Translatable|string $deathScreenMessage; private bool $keepInventory = false; private bool $keepXp = false; @@ -50,6 +51,7 @@ class PlayerDeathEvent extends EntityDeathEvent{ parent::__construct($entity, $drops, $xp); $this->player = $entity; $this->deathMessage = $deathMessage ?? self::deriveMessage($entity->getDisplayName(), $entity->getLastDamageCause()); + $this->deathScreenMessage = $this->deathMessage; } /** @@ -71,6 +73,14 @@ class PlayerDeathEvent extends EntityDeathEvent{ $this->deathMessage = $deathMessage; } + public function getDeathScreenMessage() : Translatable|string{ + return $this->deathScreenMessage; + } + + public function setDeathScreenMessage(Translatable|string $deathScreenMessage) : void{ + $this->deathScreenMessage = $deathScreenMessage; + } + public function getKeepInventory() : bool{ return $this->keepInventory; } diff --git a/src/player/Player.php b/src/player/Player.php index e8dae37f4..2c481f275 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -2344,7 +2344,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->startDeathAnimation(); - $this->getNetworkSession()->onServerDeath($ev->getDeathMessage()); + $this->getNetworkSession()->onServerDeath($ev->getDeathScreenMessage()); } protected function onDeathUpdate(int $tickDiff) : bool{