/
CreeperPowerEvent.java
89 lines (77 loc) · 2.22 KB
/
CreeperPowerEvent.java
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
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
/**
* Stores data for creepers being (un)powered
*/
public class CreeperPowerEvent extends EntityEvent implements Cancellable {
private boolean canceled;
private Entity creeper;
private PowerCause cause;
private Entity bolt;
public CreeperPowerEvent(Entity creeper, Entity bolt, PowerCause cause) {
super(Type.CREEPER_POWER, creeper);
this.creeper = creeper;
this.bolt = bolt;
this.cause = cause;
}
public CreeperPowerEvent(Entity creeper, PowerCause cause) {
super(Type.CREEPER_POWER, creeper);
this.creeper = creeper;
this.cause = cause;
this.bolt = null;
}
/**
* Gets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* @return true if this event is canceled
*/
public boolean isCancelled() {
return canceled;
}
/**
* Sets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
canceled = cancel;
}
/**
* Gets the bolt which is striking the creeper.
*
* @return lightning entity
*/
public Entity getLightning() {
return bolt;
}
/**
* Gets the cause of the creeper being (un)powered.
* @return A PowerCause value detailing the cause of change in power.
*/
public PowerCause getCause() {
return cause;
}
/**
* An enum to specify the cause of the change in power
*/
public enum PowerCause {
/**
* Power change caused by a lightning bolt
* Powered state: true
*/
LIGHTNING,
/**
* Power change caused by something else (probably a plugin)
* Powered state: true
*/
SET_ON,
/**
* Power change caused by something else (probably a plugin)
* Powered state: false
*/
SET_OFF
}
}