Skip to content

Commit

Permalink
Add context.drops to the entity death event
Browse files Browse the repository at this point in the history
Yay for additional information!
  • Loading branch information
mcmonkey4eva committed Jan 14, 2015
1 parent 1895771 commit b0ba35e
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;

import java.util.*;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -76,7 +77,8 @@ public void breakDown() {
// <context.damager> returns the dEntity damaging the other entity, if any.
// <context.message> returns an Element of a player's death message.
// <context.inventory> returns the dInventory of the entity if it was a player.
// <context.cause> returns the cause of the death.
// <context.cause> returns an Element of the cause of the death.
// <context.drops> returns a dList of all pending item drops.
//
// @Determine
// Element(String) to change the death message.
Expand All @@ -98,6 +100,16 @@ public void entityDeath(EntityDeathEvent event) {
context.put("entity", entity.getDenizenObject());
if (event.getEntity().getLastDamageCause() != null)
context.put("cause", new Element(event.getEntity().getLastDamageCause().getCause().toString()));
dList drops = new dList();
for (ItemStack stack: event.getDrops()) {
if (stack == null) {
drops.add("i@air");
}
else {
drops.add(new dItem(stack).identify());
}
}
context.put("drops", drops);

if (entity.isNPC()) npc = entity.getDenizenNPC();
else if (entity.isPlayer()) player = new dPlayer(entity.getPlayer());
Expand Down

0 comments on commit b0ba35e

Please sign in to comment.