mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
PlayerDeathEvent: add ability to set message displayed on the death screen (#5726)
This commit is contained in:
parent
bd6af68f91
commit
8245cfab0e
@ -39,6 +39,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
protected $player;
|
protected $player;
|
||||||
|
|
||||||
private Translatable|string $deathMessage;
|
private Translatable|string $deathMessage;
|
||||||
|
private Translatable|string $deathScreenMessage;
|
||||||
private bool $keepInventory = false;
|
private bool $keepInventory = false;
|
||||||
private bool $keepXp = false;
|
private bool $keepXp = false;
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
parent::__construct($entity, $drops, $xp);
|
parent::__construct($entity, $drops, $xp);
|
||||||
$this->player = $entity;
|
$this->player = $entity;
|
||||||
$this->deathMessage = $deathMessage ?? self::deriveMessage($entity->getDisplayName(), $entity->getLastDamageCause());
|
$this->deathMessage = $deathMessage ?? self::deriveMessage($entity->getDisplayName(), $entity->getLastDamageCause());
|
||||||
|
$this->deathScreenMessage = $this->deathMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +73,14 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
$this->deathMessage = $deathMessage;
|
$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{
|
public function getKeepInventory() : bool{
|
||||||
return $this->keepInventory;
|
return $this->keepInventory;
|
||||||
}
|
}
|
||||||
|
@ -2344,7 +2344,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
|
|
||||||
$this->startDeathAnimation();
|
$this->startDeathAnimation();
|
||||||
|
|
||||||
$this->getNetworkSession()->onServerDeath($ev->getDeathMessage());
|
$this->getNetworkSession()->onServerDeath($ev->getDeathScreenMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function onDeathUpdate(int $tickDiff) : bool{
|
protected function onDeathUpdate(int $tickDiff) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user