diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java index a5984ab06c..b0c069f65d 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import java.util.List; +import org.bukkit.damage.DamageSource; import org.bukkit.entity.LivingEntity; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; @@ -11,15 +12,17 @@ import org.jetbrains.annotations.NotNull; */ public class EntityDeathEvent extends EntityEvent { private static final HandlerList handlers = new HandlerList(); + private final DamageSource damageSource; private final List drops; private int dropExp = 0; - public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull final List drops) { - this(entity, drops, 0); + public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull DamageSource damageSource, @NotNull final List drops) { + this(entity, damageSource, drops, 0); } - public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull final List drops, final int droppedExp) { + public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp) { super(what); + this.damageSource = damageSource; this.drops = drops; this.dropExp = droppedExp; } @@ -30,6 +33,16 @@ public class EntityDeathEvent extends EntityEvent { return (LivingEntity) entity; } + /** + * Gets the source of damage which caused the death. + * + * @return a DamageSource detailing the source of the damage for the death. + */ + @NotNull + public DamageSource getDamageSource() { + return damageSource; + } + /** * Gets how much EXP should be dropped from this death. *

diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java index 3c2ea8fec3..133760be6c 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import java.util.List; +import org.bukkit.damage.DamageSource; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -17,16 +18,16 @@ public class PlayerDeathEvent extends EntityDeathEvent { private boolean keepLevel = false; private boolean keepInventory = false; - public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { - this(player, drops, droppedExp, 0, deathMessage); + public PlayerDeathEvent(@NotNull final Player player, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { + this(player, damageSource, drops, droppedExp, 0, deathMessage); } - public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, @Nullable final String deathMessage) { - this(player, drops, droppedExp, newExp, 0, 0, deathMessage); + public PlayerDeathEvent(@NotNull final Player player, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, final int newExp, @Nullable final String deathMessage) { + this(player, damageSource, drops, droppedExp, newExp, 0, 0, deathMessage); } - public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { - super(player, drops, droppedExp); + public PlayerDeathEvent(@NotNull final Player player, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { + super(player, damageSource, drops, droppedExp); this.newExp = newExp; this.newTotalExp = newTotalExp; this.newLevel = newLevel;