Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PortalCreateEvent.java
1 package org.bukkit.event.world;
2 
3 import org.bukkit.block.Block;
4 import org.bukkit.World;
7 
8 import java.util.ArrayList;
9 import java.util.Collection;
10 
11 /**
12  * Called when a portal is created
13  */
14 public class PortalCreateEvent extends WorldEvent implements Cancellable {
15  private static final HandlerList handlers = new HandlerList();
16  private boolean cancel = false;
17  private final ArrayList<Block> blocks = new ArrayList<Block>();
18  private CreateReason reason = CreateReason.FIRE;
19 
20  public PortalCreateEvent(final Collection<Block> blocks, final World world, CreateReason reason) {
21  super(world);
22 
23  this.blocks.addAll(blocks);
24  this.reason = reason;
25  }
26 
27  /**
28  * Gets an array list of all the blocks associated with the created portal
29  *
30  * @return array list of all the blocks associated with the created portal
31  */
32  public ArrayList<Block> getBlocks() {
33  return this.blocks;
34  }
35 
36  public boolean isCancelled() {
37  return cancel;
38  }
39 
40  public void setCancelled(boolean cancel) {
41  this.cancel = cancel;
42  }
43 
44  /**
45  * Gets the reason for the portal's creation
46  *
47  * @return CreateReason for the portal's creation
48  */
50  return reason;
51  }
52 
53  @Override
54  public HandlerList getHandlers() {
55  return handlers;
56  }
57 
58  public static HandlerList getHandlerList() {
59  return handlers;
60  }
61 
62  /**
63  * An enum to specify the various reasons for a portal's creation
64  */
65  public enum CreateReason {
66  /**
67  * When a portal is created 'traditionally' due to a portal frame
68  * being set on fire.
69  */
71  /**
72  * When a portal is created as a destination for an existing portal
73  * when using the custom PortalTravelAgent
74  */
75  OBC_DESTINATION
76  }
77 }