-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathBlockIgniteEvent.java
More file actions
148 lines (129 loc) · 3.82 KB
/
BlockIgniteEvent.java
File metadata and controls
148 lines (129 loc) · 3.82 KB
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
package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a block is ignited.
* <p>
* If this event is cancelled, the block will not be ignited.
*/
public class BlockIgniteEvent extends BlockEvent implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final IgniteCause cause;
private final Entity ignitingEntity;
private final Block ignitingBlock;
private boolean cancelled;
@ApiStatus.Internal
public BlockIgniteEvent(@NotNull final Block block, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity) {
this(block, cause, ignitingEntity, null);
}
@ApiStatus.Internal
public BlockIgniteEvent(@NotNull final Block block, @NotNull final IgniteCause cause, @NotNull final Block ignitingBlock) {
this(block, cause, null, ignitingBlock);
}
@ApiStatus.Internal
public BlockIgniteEvent(@NotNull final Block block, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity, @Nullable final Block ignitingBlock) {
super(block);
this.cause = cause;
this.ignitingEntity = ignitingEntity;
this.ignitingBlock = ignitingBlock;
}
/**
* Gets the cause of block ignite.
*
* @return An IgniteCause value detailing the cause of block ignition
*/
@NotNull
public IgniteCause getCause() {
return this.cause;
}
/**
* Gets the player who ignited this block
*
* @return The Player that placed/ignited the fire block, or {@code null} if not ignited by a Player.
*/
@Nullable
public Player getPlayer() {
if (this.ignitingEntity instanceof Player) {
return (Player) this.ignitingEntity;
}
return null;
}
/**
* Gets the entity who ignited this block
*
* @return The Entity that placed/ignited the fire block, or {@code null} if not ignited by an Entity.
*/
@Nullable
public Entity getIgnitingEntity() {
return this.ignitingEntity;
}
/**
* Gets the block which ignited this block
*
* @return The Block that placed/ignited the fire block, or {@code null} if not ignited by a Block.
*/
@Nullable
public Block getIgnitingBlock() {
return this.ignitingBlock;
}
/**
* An enum to specify the cause of the ignite
*/
public enum IgniteCause {
/**
* Block ignition caused by lava.
*/
LAVA,
/**
* Block ignition caused by a player or dispenser using flint-and-steel.
*/
FLINT_AND_STEEL,
/**
* Block ignition caused by dynamic spreading of fire.
*/
SPREAD,
/**
* Block ignition caused by lightning.
*/
LIGHTNING,
/**
* Block ignition caused by an entity using a fireball.
*/
FIREBALL,
/**
* Block ignition caused by an Ender Crystal.
*/
ENDER_CRYSTAL,
/**
* Block ignition caused by explosion.
*/
EXPLOSION,
/**
* Block ignition caused by a flaming arrow.
*/
ARROW
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
@NotNull
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}