mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 18:11:52 +00:00
parent
a38a5c67f1
commit
02cf6ae46c
@ -40,6 +40,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
|
|
||||||
private Translatable|string $deathMessage;
|
private Translatable|string $deathMessage;
|
||||||
private bool $keepInventory = false;
|
private bool $keepInventory = false;
|
||||||
|
private bool $keepXp = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item[] $drops
|
* @param Item[] $drops
|
||||||
@ -78,6 +79,14 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
$this->keepInventory = $keepInventory;
|
$this->keepInventory = $keepInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getKeepXp() : bool{
|
||||||
|
return $this->keepXp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setKeepXp(bool $keepXp) : void{
|
||||||
|
$this->keepXp = $keepXp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the vanilla death message for the given death cause.
|
* Returns the vanilla death message for the given death cause.
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +33,7 @@ use pocketmine\data\java\GameModeIdMap;
|
|||||||
use pocketmine\entity\animation\Animation;
|
use pocketmine\entity\animation\Animation;
|
||||||
use pocketmine\entity\animation\ArmSwingAnimation;
|
use pocketmine\entity\animation\ArmSwingAnimation;
|
||||||
use pocketmine\entity\animation\CriticalHitAnimation;
|
use pocketmine\entity\animation\CriticalHitAnimation;
|
||||||
|
use pocketmine\entity\Attribute;
|
||||||
use pocketmine\entity\effect\VanillaEffects;
|
use pocketmine\entity\effect\VanillaEffects;
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\entity\Human;
|
use pocketmine\entity\Human;
|
||||||
@ -2223,8 +2224,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getWorld()->dropExperience($this->location, $ev->getXpDropAmount());
|
if(!$ev->getKeepXp()){
|
||||||
$this->xpManager->setXpAndProgress(0, 0.0);
|
$this->getWorld()->dropExperience($this->location, $ev->getXpDropAmount());
|
||||||
|
$this->xpManager->setXpAndProgress(0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
if($ev->getDeathMessage() != ""){
|
if($ev->getDeathMessage() != ""){
|
||||||
$this->server->broadcastMessage($ev->getDeathMessage());
|
$this->server->broadcastMessage($ev->getDeathMessage());
|
||||||
@ -2285,6 +2288,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
$this->setHealth($this->getMaxHealth());
|
$this->setHealth($this->getMaxHealth());
|
||||||
|
|
||||||
foreach($this->attributeMap->getAll() as $attr){
|
foreach($this->attributeMap->getAll() as $attr){
|
||||||
|
if($attr->getId() === Attribute::EXPERIENCE || $attr->getId() === Attribute::EXPERIENCE_LEVEL){ //we have already reset both of those if needed when the player died
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$attr->resetToDefault();
|
$attr->resetToDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user