Implement entity max health methods. Adds BUKKIT-266

This commit is contained in:
feildmaster
2012-12-23 05:49:03 -06:00
parent 4e1793f363
commit ced0646351
10 changed files with 92 additions and 18 deletions

View File

@@ -75,7 +75,21 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public int getMaxHealth() {
return getHandle().getMaxHealth();
return getHandle().maxHealth;
}
public void setMaxHealth(int amount) {
Validate.isTrue(amount > 0, "Max health must be greater than 0");
getHandle().maxHealth = amount;
if (getHealth() > amount) {
setHealth(amount);
}
}
public void resetMaxHealth() {
setMaxHealth(getHandle().getMaxHealth());
}
@Deprecated