Added get/setLastDamageCause. Thanks sunkid!

By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
Bukkit/Spigot 2011-05-16 00:20:58 -04:00
parent 940c9f9974
commit 12a93a05ff
2 changed files with 16 additions and 3 deletions

View file

@ -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();
}

View file

@ -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);
}
/**