diff options
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/event/world/PortalCreateEvent.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/event/world/PortalCreateEvent.java b/src/main/java/org/bukkit/event/world/PortalCreateEvent.java index a2ef5ab0..6f1183a7 100644 --- a/src/main/java/org/bukkit/event/world/PortalCreateEvent.java +++ b/src/main/java/org/bukkit/event/world/PortalCreateEvent.java @@ -9,16 +9,19 @@ import java.util.ArrayList; import java.util.Collection; /** - * Called when the world attempts to create a matching end to a portal + * Called when a portal is created */ public class PortalCreateEvent extends WorldEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private final ArrayList<Block> blocks = new ArrayList<Block>(); + private CreateReason reason = CreateReason.FIRE; - public PortalCreateEvent(final Collection<Block> blocks, final World world) { + public PortalCreateEvent(final Collection<Block> blocks, final World world, CreateReason reason) { super(world); + this.blocks.addAll(blocks); + this.reason = reason; } /** @@ -38,6 +41,15 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { this.cancel = cancel; } + /** + * Gets the reason for the portal's creation + * + * @return CreateReason for the portal's creation + */ + public CreateReason getReason() { + return reason; + } + @Override public HandlerList getHandlers() { return handlers; @@ -46,4 +58,18 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { public static HandlerList getHandlerList() { return handlers; } + + /** + * An enum to specify the various reasons for a portal's creation + */ + public enum CreateReason { + /** + * When a portal is created 'traditionally' due to a portal frame being set on fire. + */ + FIRE, + /** + * When a portal is created as a destination for an existing portal when using the custom PortalTravelAgent + */ + OBC_DESTINATION + } } |