Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
BlockPistonExtendEvent.java
Go to the documentation of this file.
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;
8 import org.bukkit.block.BlockFace;
9 import org.bukkit.event.HandlerList;
10 
12  private static final HandlerList handlers = new HandlerList();
13  private final int length;
14  private List<Block> blocks;
15 
16  public BlockPistonExtendEvent(final Block block, final int length, final BlockFace direction) {
17  super(block, direction);
18 
19  this.length = length;
20  }
21 
27  public int getLength() {
28  return this.length;
29  }
30 
36  public List<Block> getBlocks() {
37  if (blocks == null) {
38  ArrayList<Block> tmp = new ArrayList<Block>();
39  for (int i = 0; i < this.getLength(); i++) {
40  tmp.add(block.getRelative(getDirection(), i + 1));
41  }
42  blocks = Collections.unmodifiableList(tmp);
43  }
44  return blocks;
45  }
46 
47  @Override
49  return handlers;
50  }
51 
52  public static HandlerList getHandlerList() {
53  return handlers;
54  }
55 }