Bukkit/Bukkit — pull request #805 by riking (2013-03-19 04:56:21+00:00)
Title: [B+C] Add heal() method to entities - BUKKIT-3641

#### The Issue:
Given a plugin where players (or any other entities) are given extra health (Let's say it's some kind of PVP) there are five main tasks to do that I can think of:
- Instant kill (`setHealth(0)`)
- Constant damage (`damage(3, DamageSource.FOO`)
- Percent damage (`damage( (int) (getMaxHealth() / 20), DamageSource.FOO)`
- Full Heal (`setHealth(getMaxHealth())`)
- Constant Heal
- Percent Heal

Absolute & Percent healing, right now, don't have an available API method - you have to use setHealth().

#### Justification for this PR:
Current method to heal an entity requires the following:
```java
// Given: int healAmount, Damageable entity
// One-line version
// Note that this runs off of the PR screen
entity.setHealth((entity.getHealth() + healAmount > entity.getMaxHealth()) ? (entity.getHealth() + healAmount) : (entity.getMaxHealth()));
// Multi-line version
int newhealth = entity.getHealth() + healAmount;
if (newhealth > entity.getMaxHealth()) {
entity.setHealth(entity.getMaxHealth()
} else {
entity.setHealth(newhealth);
}
// Or some variation thereof.
```

#### PR Breakdown:
- Adds heal(int) to Damageable.
- Adds heal(int, EntityHealEvent.HealReason) to Damageable, for when plugins want a specific heal reason for other processing.
- Adds HealReason.PLUGIN to HealReason, to provide a sane default.

##### Relevant PR(s) and other discussions:
https://github.com/Bukkit/CraftBukkit/pull/1034
https://github.com/Bukkit/CraftBukkit/commit/2f68cb8b50d87a7f34fde84bae125c69bd920cdc#comments

##### JIRA Ticket:
BUKKIT-3641 - https://bukkit.atlassian.net/browse/BUKKIT-3641