mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
SPIGOT-7650: Add DamageSource for EntityDeathEvent and PlayerDeathEvent
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
9bbcd799fa
commit
a3c30e3ee2
2 changed files with 23 additions and 9 deletions
|
@ -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<ItemStack> drops;
|
||||
private int dropExp = 0;
|
||||
|
||||
public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull final List<ItemStack> drops) {
|
||||
this(entity, drops, 0);
|
||||
public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull DamageSource damageSource, @NotNull final List<ItemStack> drops) {
|
||||
this(entity, damageSource, drops, 0);
|
||||
}
|
||||
|
||||
public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull final List<ItemStack> drops, final int droppedExp) {
|
||||
public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull DamageSource damageSource, @NotNull final List<ItemStack> 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.
|
||||
* <p>
|
||||
|
|
|
@ -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<ItemStack> 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<ItemStack> drops, final int droppedExp, @Nullable final String deathMessage) {
|
||||
this(player, damageSource, drops, droppedExp, 0, deathMessage);
|
||||
}
|
||||
|
||||
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> 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<ItemStack> 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<ItemStack> 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<ItemStack> 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;
|
||||
|
|
Loading…
Reference in a new issue