summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/event/block/BlockListener.java
blob: 237ec8f367824b679c7217c8781554595be974d8 (plain)
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
package org.bukkit.event.block;

import org.bukkit.event.Listener;

/**
 * Handles all events thrown in relation to Blocks
 */
public class BlockListener implements Listener {

    /**
     * Default Constructor
     */
    public BlockListener() {}

    /**
     * Called when a block is damaged by a player.
     * <p />
     * If a Block Damage event is cancelled, the block will not be damaged.
     *
     * @param event Relevant event details
     */
    public void onBlockDamage(BlockDamageEvent event) {}

    /**
     * Called when we try to place a block, to see if we can build it here or not.
     *<p />
     * Note:
     * <ul>
     *    <li>The Block returned by getBlock() is the block we are trying to place on, not the block we are trying to place.</li>
     *    <li>If you want to figure out what is being placed, use {@link BlockCanBuildEvent#getMaterial()} or {@link BlockCanBuildEvent#getMaterialId()} instead.</li>
     * </ul>
     *
     * @param event Relevant event details
     */
    public void onBlockCanBuild(BlockCanBuildEvent event) {}

    /**
     * Represents events with a source block and a destination block, currently only applies to liquid (lava and water).
     *<p />
     * If a Block From To event is cancelled, the block will not move (the liquid will not flow).
     *
     * @param event Relevant event details
     */
    public void onBlockFromTo(BlockFromToEvent event) {}

    /**
     * Called when a block is ignited. If you want to catch when a Player places fire, you need to use {@link BlockPlaceEvent}.
     *<p />
     * If a Block Ignite event is cancelled, the block will not be ignited.
     *
     * @param event Relevant event details
     */
    public void onBlockIgnite(BlockIgniteEvent event) {}

    /**
     * Called when block physics occurs.
     *
     * @param event Relevant event details
     */
    public void onBlockPhysics(BlockPhysicsEvent event) {}

    /**
     * Called when a block is placed by a player.
     *<p />
     * If a Block Place event is cancelled, the block will not be placed.
     *
     * @param event Relevant event details
     */
    public void onBlockPlace(BlockPlaceEvent event) {}

    /**
     * Called when redstone changes.<br />
     * From: the source of the redstone change.<br />
     * To: The redstone dust that changed.
     *
     * @param event Relevant event details
     */
    public void onBlockRedstoneChange(BlockRedstoneEvent event) {}

    /**
     * Called when leaves are decaying naturally.
     *<p />
     * If a Leaves Decay event is cancelled, the leaves will not decay.
     *
     * @param event Relevant event details
     */
    public void onLeavesDecay(LeavesDecayEvent event) {}

    /**
     * Called when a sign is changed by a player.
     * <p />
     * If a Sign Change event is cancelled, the sign will not be changed.
     *
     * @param event Relevant event details
     */
    public void onSignChange(SignChangeEvent event) {}

    /**
     * Called when a block is destroyed as a result of being burnt by fire.
     *<p />
     * If a Block Burn event is cancelled, the block will not be destroyed as a result of being burnt by fire.
     *
     * @param event Relevant event details
     */
    public void onBlockBurn(BlockBurnEvent event) {}

    /**
     * Called when a block is broken by a player.
     *<p />
     * Note:
     * Plugins wanting to simulate a traditional block drop should set the block to air and utilise their own methods for determining
     *   what the default drop for the block being broken is and what to do about it, if anything.
     *<p />
     * If a Block Break event is cancelled, the block will not break.
     *
     * @param event Relevant event details
     */
    public void onBlockBreak(BlockBreakEvent event) {}

    /**
     * Called when a block is formed or spreads based on world conditions.
     * Use {@link BlockSpreadEvent} to catch blocks that actually spread and don't just "randomly" form.
     *<p />
     * Examples:
     *<ul>
     *     <li>Snow forming due to a snow storm.</li>
     *     <li>Ice forming in a snowy Biome like Tiga or Tundra.</li>
     * </ul>
     *<p />
     * If a Block Form event is cancelled, the block will not be formed or will not spread.
     *
     * @see BlockSpreadEvent
     * @param event Relevant event details
     */
    public void onBlockForm(BlockFormEvent event) {}

    /**
     * Called when a block spreads based on world conditions.
     * Use {@link BlockFormEvent} to catch blocks that "randomly" form instead of actually spread.
     *<p />
     * Examples:
     *<ul>
     *     <li>Mushrooms spreading.</li>
     *     <li>Fire spreading.</li>
     * </ul>
     *<p />
     * If a Block Spread event is cancelled, the block will not spread.
     *
     * @param event Relevant event details
     */
    public void onBlockSpread(BlockSpreadEvent event) {}

    /**
     * Called when a block fades, melts or disappears based on world conditions
     * <p />
     * Examples:
     * <ul>
     *     <li>Snow melting due to being near a light source.</li>
     *     <li>Ice melting due to being near a light source.</li>
     * </ul>
     * <p />
     * If a Block Fade event is cancelled, the block will not fade, melt or disappear.
     *
     * @param event Relevant event details
     */
    public void onBlockFade(BlockFadeEvent event) {}

    /**
     * Called when an item is dispensed from a block.
     *<p />
     * If a Block Dispense event is cancelled, the block will not dispense the item.
     *
     * @param event Relevant event details
     */
    public void onBlockDispense(BlockDispenseEvent event) {}

    /**
     * Called when a piston retracts
     *
     * @param event Relevant event details
     */
    public void onBlockPistonRetract(BlockPistonRetractEvent event) {}

    /**
     * Called when a piston extends
     *
     * @param event Relevant event details
     */
    public void onBlockPistonExtend(BlockPistonExtendEvent event) {}
}