Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockPistonExtendEvent.java
1 package org.bukkit.event.block;
2 
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.List;
6 
7 import org.bukkit.block.Block;
10 
11 /**
12  * Called when a piston extends
13  */
15  private static final HandlerList handlers = new HandlerList();
16  private final int length;
17  private List<Block> blocks;
18 
19  public BlockPistonExtendEvent(final Block block, final int length, final BlockFace direction) {
20  super(block, direction);
21 
22  this.length = length;
23  }
24 
25  /**
26  * Get the amount of blocks which will be moved while extending.
27  *
28  * @return the amount of moving blocks
29  */
30  public int getLength() {
31  return this.length;
32  }
33 
34  /**
35  * Get an immutable list of the blocks which will be moved by the
36  * extending.
37  *
38  * @return Immutable list of the moved blocks.
39  */
40  public List<Block> getBlocks() {
41  if (blocks == null) {
42  ArrayList<Block> tmp = new ArrayList<Block>();
43  for (int i = 0; i < this.getLength(); i++) {
44  tmp.add(block.getRelative(getDirection(), i + 1));
45  }
46  blocks = Collections.unmodifiableList(tmp);
47  }
48  return blocks;
49  }
50 
51  @Override
52  public HandlerList getHandlers() {
53  return handlers;
54  }
55 
56  public static HandlerList getHandlerList() {
57  return handlers;
58  }
59 }
Block getRelative(int modX, int modY, int modZ)