Add ability to keep items on death via plugins. Adds BUKKIT-5724

When a player dies their inventory is normally scattered over the the area
in which they died. Plugins should be able to modify this behaviour by
defining whether or not the player's inventory will be dropped on the ground or
waiting for the player when they eventually respawn.

This commit adds the methods required to the PlayerDeathEvent for plugins
to be able to incorporate the behaviour mentioned as a simple boolean
flag.
This commit is contained in:
Jerom van der Sar 2014-07-31 02:58:06 +02:00 committed by turt2live
parent f0ab5b0aec
commit 1c220ddc6e

View file

@ -14,6 +14,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
private int newLevel = 0;
private int newTotalExp = 0;
private boolean keepLevel = false;
private boolean keepInventory = false;
public PlayerDeathEvent(final Player player, final List<ItemStack> drops, final int droppedExp, final String deathMessage) {
this(player, drops, droppedExp, 0, deathMessage);
@ -135,4 +136,22 @@ public class PlayerDeathEvent extends EntityDeathEvent {
public void setKeepLevel(boolean keepLevel) {
this.keepLevel = keepLevel;
}
/**
* Sets if the Player keeps inventory on death.
*
* @param keepInventory True to keep the inventory
*/
public void setKeepInventory(boolean keepInventory) {
this.keepInventory = keepInventory;
}
/**
* Gets if the Player keeps inventory on death.
*
* @return True if the player keeps inventory on death
*/
public boolean getKeepInventory() {
return keepInventory;
}
}