Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.event.entity;
2
3import org.bukkit.entity.Entity;
4import org.bukkit.event.Cancellable;
5import org.bukkit.event.Event;
6
7/**
8 * Stores data for health-regain events
9 */
10public class EntityRegainHealthEvent extends EntityEvent implements Cancellable {
11
12 private boolean cancelled;
13 private int amount;
14 private RegainReason regainReason;
15
16 public EntityRegainHealthEvent(Entity entity, int amount, RegainReason regainReason) {
17 super(Event.Type.ENTITY_REGAIN_HEALTH, entity);
18 this.amount = amount;
19 this.regainReason = regainReason;
20 }
21
22 /**
23 * Gets the amount of regained health
24 *
25 * @return The amount of health regained
26 */
27 public int getAmount() {
28 return amount;
29 }
30
31 /**
32 * Sets the amount of regained health
33 *
34 * @param amount the amount of health the entity will regain
35 */
36 public void setAmount(int amount) {
37 this.amount = amount;
38 }
39
40 public boolean isCancelled() {
41 return cancelled;
42 }
43
44 public void setCancelled(boolean cancel) {
45 cancelled = cancel;
46 }
47
48 /**
49 * Gets the reason for why the entity is regaining health
50 *
51 * @return A RegainReason detailing the reason for the entity regaining health
52 */
53 public RegainReason getRegainReason() {
54 return regainReason;
55 }
56
57 /**
58 * An enum to specify the type of health regaining that is occurring
59 */
60 public enum RegainReason {
61
62 /**
63 * When a player regains health from regenerating due to Peaceful mode (spawn-monsters=false)
64 */
65 REGEN,
66 /**
67 * When a player regains health from eating consumables
68 */
69 EATING,
70 /**
71 * Any other reason not covered by the reasons above
72 */
73 CUSTOM
74 }
75}