summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfeildmaster <admin@feildmaster.com>2012-12-23 03:28:01 -0600
committerfeildmaster <admin@feildmaster.com>2012-12-23 07:28:37 -0600
commit286f4565ac608bee905c9c195e4aa768df7bc1b7 (patch)
treee3877932accd0a565a3758ed82f3a83cb4557546
parentdf6049eaa167f0df8b527f2c5f2378a64555204a (diff)
downloadbukkit-286f4565ac608bee905c9c195e4aa768df7bc1b7.tar
bukkit-286f4565ac608bee905c9c195e4aa768df7bc1b7.tar.gz
bukkit-286f4565ac608bee905c9c195e4aa768df7bc1b7.tar.lz
bukkit-286f4565ac608bee905c9c195e4aa768df7bc1b7.tar.xz
bukkit-286f4565ac608bee905c9c195e4aa768df7bc1b7.zip
Add methods to set and reset max health. Adds BUKKIT-266
-rw-r--r--src/main/java/org/bukkit/entity/Damageable.java59
-rw-r--r--src/main/java/org/bukkit/entity/EnderDragonPart.java2
-rw-r--r--src/main/java/org/bukkit/entity/LivingEntity.java40
3 files changed, 61 insertions, 40 deletions
diff --git a/src/main/java/org/bukkit/entity/Damageable.java b/src/main/java/org/bukkit/entity/Damageable.java
new file mode 100644
index 00000000..3ce7c5cf
--- /dev/null
+++ b/src/main/java/org/bukkit/entity/Damageable.java
@@ -0,0 +1,59 @@
+package org.bukkit.entity;
+
+/**
+ * Represents an {@link Entity} that has health and can take damage.
+ */
+public interface Damageable extends Entity {
+ /**
+ * Deals the given amount of damage to this entity.
+ *
+ * @param amount Amount of damage to deal
+ */
+ void damage(int amount);
+
+ /**
+ * Deals the given amount of damage to this entity, from a specified entity.
+ *
+ * @param amount Amount of damage to deal
+ * @param source Entity which to attribute this damage from
+ */
+ void damage(int amount, Entity source);
+
+ /**
+ * Gets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead.
+ *
+ * @return Health represented from 0 to max
+ */
+ int getHealth();
+
+ /**
+ * Sets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead.
+ *
+ * @param health New health represented from 0 to max
+ * @throws IllegalArgumentException Thrown if the health is < 0 or > {@link #getMaxHealth()}
+ */
+ void setHealth(int health);
+
+ /**
+ * Gets the maximum health this entity has.
+ *
+ * @return Maximum health
+ */
+ int getMaxHealth();
+
+ /**
+ * Sets the maximum health this entity can have.
+ * <p />
+ * If the health of the entity is above the value provided it will be set to that value.
+ * <p />
+ * Note: An entity with a health bar ({@link Player}, {@link EnderDragon}, {@link Wither}, etc...} will have their bar scaled accordingly.
+ *
+ * @param health amount of health to set the maximum to
+ */
+ void setMaxHealth(int health);
+
+ /**
+ * Resets the max health to the original amount.
+ */
+ void resetMaxHealth();
+}
diff --git a/src/main/java/org/bukkit/entity/EnderDragonPart.java b/src/main/java/org/bukkit/entity/EnderDragonPart.java
index 4bb822a3..9516f566 100644
--- a/src/main/java/org/bukkit/entity/EnderDragonPart.java
+++ b/src/main/java/org/bukkit/entity/EnderDragonPart.java
@@ -3,6 +3,6 @@ package org.bukkit.entity;
/**
* Represents an ender dragon part
*/
-public interface EnderDragonPart extends ComplexEntityPart {
+public interface EnderDragonPart extends ComplexEntityPart, Damageable {
public EnderDragon getParent();
}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 870b4619..4a6ceb00 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -13,30 +13,7 @@ import org.bukkit.potion.PotionEffectType;
/**
* Represents a living entity, such as a monster or player
*/
-public interface LivingEntity extends Entity {
-
- /**
- * Gets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead
- *
- * @return Health represented from 0 to max
- */
- public int getHealth();
-
- /**
- * Sets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead
- *
- * @param health New health represented from 0 to max
- * @throws IllegalArgumentException Thrown if the health is < 0 or > max
- */
- public void setHealth(int health);
-
- /**
- * Gets the maximum health this entity may have
- *
- * @return Maximum health
- */
- public int getMaxHealth();
-
+public interface LivingEntity extends Entity, Damageable {
/**
* Gets the height of the entity's head above its Location
*
@@ -153,21 +130,6 @@ public interface LivingEntity extends Entity {
public void setMaximumAir(int ticks);
/**
- * Deals the given amount of damage to this entity
- *
- * @param amount Amount of damage to deal
- */
- public void damage(int amount);
-
- /**
- * Deals the given amount of damage to this entity, from a specified entity
- *
- * @param amount Amount of damage to deal
- * @param source Entity which to attribute this damage from
- */
- public void damage(int amount, Entity source);
-
- /**
* Returns the entities current maximum noDamageTicks
* This is the time in ticks the entity will become unable to take
* equal or less damage than the lastDamage