1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Stores data for damage events
*/
public class EntityDamageEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private int damage;
private boolean cancelled;
private final DamageCause cause;
public EntityDamageEvent(final Entity damagee, final DamageCause cause, final int damage) {
super(damagee);
this.cause = cause;
this.damage = damage;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* Gets the amount of damage caused by the event
*
* @return The amount of damage caused by the event
*/
public int getDamage() {
return damage;
}
/**
* Sets the amount of damage caused by the event
*
* @param damage The amount of damage caused by the event
*/
public void setDamage(int damage) {
this.damage = damage;
}
/**
* Gets the cause of the damage.
*
* @return A DamageCause value detailing the cause of the damage.
*/
public DamageCause getCause() {
return cause;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* An enum to specify the cause of the damage
*/
public enum DamageCause {
/**
* Damage caused when an entity contacts a block such as a Cactus.
* <p />
* Damage: 1 (Cactus)
*/
CONTACT,
/**
* Damage caused when an entity attacks another entity.
* <p />
* Damage: variable
*/
ENTITY_ATTACK,
/**
* Damage caused when attacked by a projectile.
* <p />
* Damage: variable
*/
PROJECTILE,
/**
* Damage caused by being put in a block
* <p />
* Damage: 1
*/
SUFFOCATION,
/**
* Damage caused when an entity falls a distance greater than 3 blocks
* <p />
* Damage: fall height - 3.0
*/
FALL,
/**
* Damage caused by direct exposure to fire
* <p />
* Damage: 1
*/
FIRE,
/**
* Damage caused due to burns caused by fire
* <p />
* Damage: 1
*/
FIRE_TICK,
/**
* Damage caused due to a snowman melting
* <p />
* Damage: 1
*/
MELTING,
/**
* Damage caused by direct exposure to lava
* <p />
* Damage: 4
*/
LAVA,
/**
* Damage caused by running out of air while in water
* <p />
* Damage: 2
*/
DROWNING,
/**
* Damage caused by being in the area when a block explodes.
* <p />
* Damage: variable
*/
BLOCK_EXPLOSION,
/**
* Damage caused by being in the area when an entity, such as a Creeper, explodes.
* <p />
* Damage: variable
*/
ENTITY_EXPLOSION,
/**
* Damage caused by falling into the void
* <p />
* Damage: 4 for players
*/
VOID,
/**
* Damage caused by being struck by lightning
* <p />
* Damage: 5
*/
LIGHTNING,
/**
* Damage caused by committing suicide using the command "/kill"
* <p />
* Damage: 1000
*/
SUICIDE,
/**
* Damage caused by starving due to having an empty hunger bar
* <p />
* Damage: 1
*/
STARVATION,
/**
* Damage caused due to an ongoing poison effect
* <p />
* Damage: 1
*/
POISON,
/**
* Damage caused by being hit by a damage potion or spell
* <p />
* Damage: variable
*/
MAGIC,
/**
*
*/
WITHER,
/**
* Damage caused by being hit by a falling block which deals damage
* <p />
* <b>Note:</b> Not every block deals damage
* <p />
* Damage: variable
*/
FALLING_BLOCK,
/**
* Damage caused in retaliation to another attack by the Thorns enchantment.
* <p />
* Damage: 1-4 (Thorns)
*/
THORNS,
/**
* Custom damage.
* <p />
* Damage: variable
*/
CUSTOM
}
}
|