diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index adfaddf302..84673b4691 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -366,7 +366,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { IChatBaseComponent chatmessage = this.aW().b(); String deathmessage = chatmessage.c(); - org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage); + org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); String deathMessage = event.getDeathMessage(); @@ -379,7 +379,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. - if (!keepInventory) { + if (!event.getKeepInventory()) { for (int i = 0; i < this.inventory.items.length; ++i) { this.inventory.items[i] = null; } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0fff227f17..9b10c418e1 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -372,9 +372,10 @@ public class CraftEventFactory { return event; } - public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List drops, String deathMessage) { + public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List 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;