Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
StructureGrowEvent.java
1 package org.bukkit.event.world;
2 
3 import java.util.List;
4 import org.bukkit.Location;
5 import org.bukkit.TreeType;
7 import org.bukkit.entity.Player;
10 
11 /**
12  * Event that is called when an organic structure attempts to grow (Sapling ->
13  * Tree), (Mushroom -> Huge Mushroom), naturally or using bonemeal.
14  */
15 public class StructureGrowEvent extends WorldEvent implements Cancellable {
16  private static final HandlerList handlers = new HandlerList();
17  private boolean cancelled = false;
18  private final Location location;
19  private final TreeType species;
20  private final boolean bonemeal;
21  private final Player player;
22  private final List<BlockState> blocks;
23 
24  public StructureGrowEvent(final Location location, final TreeType species, final boolean bonemeal, final Player player, final List<BlockState> blocks) {
25  super(location.getWorld());
26  this.location = location;
27  this.species = species;
28  this.bonemeal = bonemeal;
29  this.player = player;
30  this.blocks = blocks;
31  }
32 
33  /**
34  * Gets the location of the structure.
35  *
36  * @return Location of the structure
37  */
38  public Location getLocation() {
39  return location;
40  }
41 
42  /**
43  * Gets the species type (birch, normal, pine, red mushroom, brown
44  * mushroom)
45  *
46  * @return Structure species
47  */
48  public TreeType getSpecies() {
49  return species;
50  }
51 
52  /**
53  * Checks if structure was grown using bonemeal.
54  *
55  * @return True if the structure was grown using bonemeal.
56  */
57  public boolean isFromBonemeal() {
58  return bonemeal;
59  }
60 
61  /**
62  * Gets the player that created the structure.
63  *
64  * @return Player that created the structure, null if was not created
65  * manually
66  */
67  public Player getPlayer() {
68  return player;
69  }
70 
71  /**
72  * Gets an ArrayList of all blocks associated with the structure.
73  *
74  * @return ArrayList of all blocks associated with the structure.
75  */
76  public List<BlockState> getBlocks() {
77  return blocks;
78  }
79 
80  public boolean isCancelled() {
81  return cancelled;
82  }
83 
84  public void setCancelled(boolean cancel) {
85  cancelled = cancel;
86  }
87 
88  @Override
89  public HandlerList getHandlers() {
90  return handlers;
91  }
92 
93  public static HandlerList getHandlerList() {
94  return handlers;
95  }
96 }