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 damage events
9 */
10public class EntityDamageEvent extends EntityEvent implements Cancellable {
11
12 private int damage;
13 private boolean cancelled;
14 private DamageCause cause;
15
16 public EntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
17 this(Event.Type.ENTITY_DAMAGE, damagee, cause, damage);
18 }
19
20 protected EntityDamageEvent(Event.Type type, Entity damagee, DamageCause cause, int damage) {
21 super(type, damagee);
22 this.cause = cause;
23 this.damage = damage;
24
25 damagee.setLastDamageCause(this);
26 }
27
28 public boolean isCancelled() {
29 return cancelled;
30 }
31
32 public void setCancelled(boolean cancel) {
33 cancelled = cancel;
34 }
35
36 /**
37 * Gets the amount of damage caused by the Block
38 *
39 * @return The amount of damage caused by the Block
40 */
41 public int getDamage() {
42 return damage;
43 }
44
45 /**
46 * Sets the amount of damage caused by the Block
47 *
48 * @param damage The amount of damage caused by the Block
49 */
50 public void setDamage(int damage) {
51 this.damage = damage;
52 }
53
54 /**
55 * Gets the cause of the damage.
56 *
57 * @return A DamageCause value detailing the cause of the damage.
58 */
59 public DamageCause getCause() {
60 return cause;
61 }
62
63 /**
64 * An enum to specify the cause of the damage
65 */
66 public enum DamageCause {
67
68 /**
69 * Damage caused when an entity contacts a block such as a Cactus.
70 * <p>
71 * Damage: 1 (Cactus)
72 */
73 CONTACT,
74 /**
75 * Damage caused when an entity attacks another entity.
76 * <p>
77 * Damage: variable
78 */
79 ENTITY_ATTACK,
80 /**
81 * Damage caused when attacked by a projectile.
82 * <p>
83 * Damage: variable
84 */
85 PROJECTILE,
86 /**
87 * Damage caused by being put in a block
88 * <p>
89 * Damage: 1
90 */
91 SUFFOCATION,
92 /**
93 * Damage caused when an entity falls a distance greater than 3 blocks
94 * <p>
95 * Damage: fall height - 3.0
96 */
97 FALL,
98 /**
99 * Damage caused by direct exposure to fire
100 * <p>
101 * Damage: 1
102 */
103 FIRE,
104 /**
105 * Damage caused due to burns caused by fire
106 * <p>
107 * Damage: 1
108 */
109 FIRE_TICK,
110 /**
111 * Damage caused by direct exposure to lava
112 * <p>
113 * Damage: 4
114 */
115 LAVA,
116 /**
117 * Damage caused by running out of air while in water
118 * <p>
119 * Damage: 2
120 */
121 DROWNING,
122 /**
123 * Damage caused by being in the area when a block explodes.
124 * <p>
125 * Damage: variable
126 */
127 BLOCK_EXPLOSION,
128 /**
129 * Damage caused by being in the area when a block of TNT explodes.
130 */
131 TNT_EXPLOSION,
132 /**
133 * Damage caused by being in the area when a bed explodes.
134 */
135 BED_EXPLOSION,
136 /**
137 * Damage caused by being in the area when a plugin causes an explosion
138 */
139 PLUGIN_EXPLOSION,
140 /**
141 * Damage caused by being in the area when an entity, such as a Creeper, explodes.
142 * <p>
143 * Damage: variable
144 */
145 ENTITY_EXPLOSION,
146 /**
147 * Damage caused by falling into the void
148 * <p>
149 * Damage: 4 for players
150 */
151 VOID,
152 /**
153 * Damage caused by being struck by lightning
154 * <p>
155 * Damage: 5
156 */
157 LIGHTNING,
158 /**
159 * Damage caused by committing suicide using the command "/kill"
160 * <p>
161 * Damage: 1000
162 */
163 SUICIDE,
164 /**
165 * Custom damage.
166 * <p>
167 * Damage: variable
168 */
169 CUSTOM
170 }
171}