mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Added PlayerDeathEvent methods for inventory keeping
This commit is contained in:
parent
94eb9e35e2
commit
eccf7b08d2
@ -2436,12 +2436,15 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
Entity::kill();
|
Entity::kill();
|
||||||
|
|
||||||
$this->server->getPluginManager()->callEvent($ev = new PlayerDeathEvent($this, $this->getDrops(), $message));
|
$this->server->getPluginManager()->callEvent($ev = new PlayerDeathEvent($this, $this->getDrops(), $message));
|
||||||
foreach($ev->getDrops() as $item){
|
|
||||||
$this->getLevel()->dropItem($this, $item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->inventory !== null){
|
if(!$ev->getKeepInventory()){
|
||||||
$this->inventory->clearAll();
|
foreach($ev->getDrops() as $item){
|
||||||
|
$this->getLevel()->dropItem($this, $item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->inventory !== null){
|
||||||
|
$this->inventory->clearAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ev->getDeathMessage() != ""){
|
if($ev->getDeathMessage() != ""){
|
||||||
|
@ -29,6 +29,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
public static $handlerList = null;
|
public static $handlerList = null;
|
||||||
|
|
||||||
private $deathMessage;
|
private $deathMessage;
|
||||||
|
private $keepInventory = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player $entity
|
* @param Player $entity
|
||||||
@ -55,4 +56,12 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
|||||||
$this->deathMessage = $deathMessage;
|
$this->deathMessage = $deathMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getKeepInventory(){
|
||||||
|
return $this->keepInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setKeepInventory($keepInventory){
|
||||||
|
$this->keepInventory = (bool) $keepInventory;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user