mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
Implement 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 implements the methods included in the Bukkit half for the new behaviour by acting upon the boolean flag. The boolean flag is tested prior to clearing the inventory as well as prior to dropping the items on the ground. If the flag is true (indicating "keep inventory"), the items are not removed from the player's inventory and are not dropped on the ground. By: Jerom van der Sar <jerom.sar@hotmail.com>
This commit is contained in:
parent
5d8e9e97fd
commit
02fb3fd3d7
1 changed files with 6 additions and 1 deletions
|
@ -372,9 +372,10 @@ public class CraftEventFactory {
|
|||
return event;
|
||||
}
|
||||
|
||||
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
|
||||
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage, boolean keepInventory) {
|
||||
CraftPlayer entity = victim.getBukkitEntity();
|
||||
PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
|
||||
event.setKeepInventory(keepInventory);
|
||||
org.bukkit.World world = entity.getWorld();
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
|
@ -384,6 +385,10 @@ public class CraftEventFactory {
|
|||
victim.expToDrop = event.getDroppedExp();
|
||||
victim.newExp = event.getNewExp();
|
||||
|
||||
if (event.getKeepInventory()) {
|
||||
return event;
|
||||
}
|
||||
|
||||
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
||||
if (stack == null || stack.getType() == Material.AIR) continue;
|
||||
|
||||
|
|
Loading…
Reference in a new issue