Commits
DerFrZocker authored and md_5 committed 9a80d38c002
1 + | package org.bukkit.event.entity; |
2 + | |
3 + | import org.bukkit.entity.Entity; |
4 + | import org.bukkit.event.HandlerList; |
5 + | import org.jetbrains.annotations.ApiStatus; |
6 + | import org.jetbrains.annotations.NotNull; |
7 + | |
8 + | /** |
9 + | * Called when an {@link Entity} is removed. |
10 + | * <p> |
11 + | * This event should only be used for monitoring. The result |
12 + | * of modifying the entity during or after this event is unspecified. |
13 + | * This event is not called for a {@link org.bukkit.entity.Player}. |
14 + | */ |
15 + | Experimental | .
16 + | public class EntityRemoveEvent extends EntityEvent { |
17 + | |
18 + | private static final HandlerList handlers = new HandlerList(); |
19 + | private final Cause cause; |
20 + | |
21 + | public EntityRemoveEvent( Entity what, Cause cause) { |
22 + | super(what); |
23 + | this.cause = cause; |
24 + | } |
25 + | |
26 + | /** |
27 + | * Gets the cause why the entity got removed. |
28 + | * |
29 + | * @return the cause why the entity got removed |
30 + | */ |
31 + | |
32 + | public Cause getCause() { |
33 + | return cause; |
34 + | } |
35 + | |
36 + | |
37 + | |
38 + | public HandlerList getHandlers() { |
39 + | return handlers; |
40 + | } |
41 + | |
42 + | |
43 + | public static HandlerList getHandlerList() { |
44 + | return handlers; |
45 + | } |
46 + | |
47 + | /** |
48 + | * Represents various ways an entity gets removed. |
49 + | */ |
50 + | public enum Cause { |
51 + | /** |
52 + | * When an entity dies. |
53 + | */ |
54 + | DEATH, |
55 + | /** |
56 + | * When an entity does despawn. This includes mobs which are too far away, |
57 + | * items or arrows which lay to long on the ground or area effect cloud. |
58 + | */ |
59 + | DESPAWN, |
60 + | /** |
61 + | * When an entity gets removed because it drops as an item. |
62 + | * For example, trident or falling sand. |
63 + | * <p> |
64 + | * <b>Note:</b> Depending on other factors, such as gamerules, no item will actually drop, |
65 + | * the cause, however, will still be drop. |
66 + | */ |
67 + | DROP, |
68 + | /** |
69 + | * When an entity gets removed because it enters a block. |
70 + | * For example, bees or silverfish. |
71 + | */ |
72 + | ENTER_BLOCK, |
73 + | /** |
74 + | * When an entity gets removed because it exploded. |
75 + | * For example, creepers, tnt or firework. |
76 + | */ |
77 + | EXPLODE, |
78 + | /** |
79 + | * When an entity gets removed because it hit something. This mainly applies to projectiles. |
80 + | */ |
81 + | HIT, |
82 + | /** |
83 + | * When an entity gets removed because it merges with another one. |
84 + | * For example, items or xp. |
85 + | */ |
86 + | MERGE, |
87 + | /** |
88 + | * When an entity gets removed because it is too far below the world. |
89 + | * This only applies to entities which get removed immediately, |
90 + | * some entities get damage instead. |
91 + | */ |
92 + | OUT_OF_WORLD, |
93 + | /** |
94 + | * When an entity gets removed because it got pickup. |
95 + | * For example, items, arrows, xp or parrots which get on a player shoulder. |
96 + | */ |
97 + | PICKUP, |
98 + | /** |
99 + | * When an entity gets removed with a player because the player quits the game. |
100 + | * For example, a boat which gets removed with the player when he quits. |
101 + | */ |
102 + | PLAYER_QUIT, |
103 + | /** |
104 + | * When a plugin manually removes an entity. |
105 + | */ |
106 + | PLUGIN, |
107 + | /** |
108 + | * When an entity gets removed because it transforms into another one. |
109 + | */ |
110 + | TRANSFORMATION, |
111 + | /** |
112 + | * When the chunk an entity is in gets unloaded. |
113 + | */ |
114 + | UNLOAD, |
115 + | } |
116 + | } |