Move health stuff from LivingEntity to Entity.

By: angelsl <angelsl@rpm>
This commit is contained in:
Bukkit/Spigot 2011-01-03 17:40:26 +08:00
parent b2817db6b7
commit d3240391ad
4 changed files with 25 additions and 11 deletions

View file

@ -32,4 +32,17 @@ public interface Entity {
* @return Entity ID * @return Entity ID
*/ */
public int getEntityID(); public int getEntityID();
/**
* Gets the entitys health from 0-20, where 0 is dead and 20 is full
*
* @return Health represented from 0-20
*/
public int getHealth();
/**
* Sets the entitys health from 0-20, where 0 is dead and 20 is full
*
* @param health New health represented from 0-20
*/
public void setHealth(int health);
} }

View file

@ -15,7 +15,7 @@ public class EntityDamagedByBlockEvent extends EntityEvent implements Cancellabl
private int damage; private int damage;
private boolean cancelled; private boolean cancelled;
public EntityDamagedByBlockEvent(Block damager, LivingEntity damagee, int damage) public EntityDamagedByBlockEvent(Block damager, Entity damagee, int damage)
{ {
super(Event.Type.ENTITY_DAMAGEDBY_BLOCK, damagee); super(Event.Type.ENTITY_DAMAGEDBY_BLOCK, damagee);
this.damager = damager; this.damager = damager;

View file

@ -11,11 +11,11 @@ import org.bukkit.event.Event;
*/ */
public class EntityDamagedByEntityEvent extends EntityEvent implements Cancellable { public class EntityDamagedByEntityEvent extends EntityEvent implements Cancellable {
private LivingEntity damager; private Entity damager;
private int damage; private int damage;
private boolean cancelled; private boolean cancelled;
public EntityDamagedByEntityEvent(LivingEntity damager, LivingEntity damagee, int damage) public EntityDamagedByEntityEvent(Entity damager, Entity damagee, int damage)
{ {
super(Event.Type.ENTITY_DAMAGEDBY_ENTITY, damagee); super(Event.Type.ENTITY_DAMAGEDBY_ENTITY, damagee);
this.damager = damager; this.damager = damager;
@ -49,9 +49,9 @@ public class EntityDamagedByEntityEvent extends EntityEvent implements Cancellab
/** /**
* Returns the entity that damaged the player. * Returns the entity that damaged the player.
* @return LivingEntity that damaged the player * @return Entity that damaged the player
*/ */
public LivingEntity getDamager() public Entity getDamager()
{ {
return damager; return damager;
} }

View file

@ -1,25 +1,26 @@
package org.bukkit.event.entity; package org.bukkit.event.entity;
import org.bukkit.Entity;
import org.bukkit.LivingEntity; import org.bukkit.LivingEntity;
import org.bukkit.event.Event; import org.bukkit.event.Event;
/** /**
* Represents an LivingEntity-related event * Represents an Entity-related event
*/ */
public class EntityEvent extends Event { public class EntityEvent extends Event {
protected LivingEntity entity; protected Entity entity;
public EntityEvent(final Event.Type type, final LivingEntity what) public EntityEvent(final Event.Type type, final Entity what)
{ {
super(type); super(type);
entity = what; entity = what;
} }
/** /**
* Returns the LivingEntity involved in this event * Returns the Entity involved in this event
* @return LivingEntity who is involved in this event * @return Entity who is involved in this event
*/ */
public final LivingEntity getEntity() public final Entity getEntity()
{ {
return entity; return entity;
} }