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;
5
6/**
7 * Called when a Creeper is struck by lightning.
8 * <p/>
9 * If a Creeper Power event is cancelled, the Creeper will not be powered.
10 */
11public class CreeperPowerEvent extends EntityEvent implements Cancellable {
12
13 private boolean canceled;
14 private Entity creeper;
15 private PowerCause cause;
16 private Entity bolt;
17
18 public CreeperPowerEvent(Entity creeper, Entity bolt, PowerCause cause) {
19 super(Type.CREEPER_POWER, creeper);
20 this.creeper = creeper;
21 this.bolt = bolt;
22 this.cause = cause;
23 }
24
25 public CreeperPowerEvent(Entity creeper, PowerCause cause) {
26 super(Type.CREEPER_POWER, creeper);
27 this.creeper = creeper;
28 this.cause = cause;
29 this.bolt = null;
30 }
31
32 public boolean isCancelled() {
33 return canceled;
34 }
35
36 public void setCancelled(boolean cancel) {
37 canceled = cancel;
38 }
39
40 /**
41 * Gets the lightning bolt which is striking the Creeper.
42 *
43 * @return The Entity for the lightning bolt which is striking the Creeper
44 */
45 public Entity getLightning() {
46 return bolt;
47 }
48
49 /**
50 * Gets the cause of the creeper being (un)powered.
51 *
52 * @return A PowerCause value detailing the cause of change in power.
53 */
54 public PowerCause getCause() {
55 return cause;
56 }
57
58 /**
59 * An enum to specify the cause of the change in power
60 */
61 public enum PowerCause {
62
63 /**
64 * Power change caused by a lightning bolt
65 * Powered state: true
66 */
67 LIGHTNING,
68 /**
69 * Power change caused by something else (probably a plugin)
70 * Powered state: true
71 */
72 SET_ON,
73 /**
74 * Power change caused by something else (probably a plugin)
75 * Powered state: false
76 */
77 SET_OFF
78 }
79}