mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
Added get/setLastDamageCause. Thanks sunkid!
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
940c9f9974
commit
12a93a05ff
2 changed files with 16 additions and 3 deletions
|
@ -3,6 +3,7 @@ package org.bukkit.entity;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -169,4 +170,16 @@ public interface Entity {
|
|||
*/
|
||||
public void setFallDistance(float distance);
|
||||
|
||||
/**
|
||||
* Record the last {@link EntityDamageEvent} inflicted on this entity
|
||||
* @param event a {@link EntityDamageEvent}
|
||||
*/
|
||||
public void setLastDamageCause(EntityDamageEvent event);
|
||||
|
||||
/**
|
||||
* Retrieve the last {@link EntityDamageEvent} inflicted on this entity. This event may have been cancelled.
|
||||
* @return the last known {@link EntityDamageEvent} or null if hitherto unharmed
|
||||
*/
|
||||
public EntityDamageEvent getLastDamageCause();
|
||||
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
|
|||
private DamageCause cause;
|
||||
|
||||
public EntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||
super(Event.Type.ENTITY_DAMAGE, damagee);
|
||||
this.cause = cause;
|
||||
this.damage = damage;
|
||||
this(Event.Type.ENTITY_DAMAGE, damagee, cause, damage);
|
||||
}
|
||||
|
||||
protected EntityDamageEvent(Event.Type type, Entity damagee, DamageCause cause, int damage) {
|
||||
super(type, damagee);
|
||||
this.cause = cause;
|
||||
this.damage = damage;
|
||||
|
||||
damagee.setLastDamageCause(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue