Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.event.block;
2
3import org.bukkit.block.Block;
4
5import java.util.ArrayList;
6import java.util.Collections;
7import java.util.List;
8
9public class BlockPistonExtendEvent extends BlockPistonEvent {
10 private int length;
11 private List<Block> blocks;
12
13 public BlockPistonExtendEvent(Block block, int length) {
14 super(Type.BLOCK_PISTON_EXTEND, block);
15
16 this.length = length;
17 }
18
19 /**
20 * Get the amount of blocks which will be moved while extending.
21 *
22 * @return the amount of moving blocks
23 */
24 public int getLength() {
25 return this.length;
26 }
27
28 /**
29 * Get an immutable list of the blocks which will be moved by the extending.
30 *
31 * @return Immutable list of the moved blocks.
32 */
33 public List<Block> getBlocks() {
34 if (blocks == null) {
35 ArrayList<Block> tmp = new ArrayList<Block>();
36 for (int i = 0; i < this.getLength(); i++) {
37 tmp.add(block.getRelative(getDirection(), i + 1));
38 }
39 blocks = Collections.unmodifiableList(tmp);
40 }
41 return blocks;
42 }
43}