diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-15 11:58:03 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-15 11:58:03 +0000 |
commit | a10057b54164eef24bbd99708d7b759bed29f281 (patch) | |
tree | abb5ec24a37e4761782700f93193859b924fd817 | |
parent | ea3e91b416f82432dbf4304bc627a2ad48b2690e (diff) | |
download | bukkit-a10057b54164eef24bbd99708d7b759bed29f281.tar bukkit-a10057b54164eef24bbd99708d7b759bed29f281.tar.gz bukkit-a10057b54164eef24bbd99708d7b759bed29f281.tar.lz bukkit-a10057b54164eef24bbd99708d7b759bed29f281.tar.xz bukkit-a10057b54164eef24bbd99708d7b759bed29f281.zip |
Added an EntityCreatePortalEvent
5 files changed, 90 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/PortalType.java b/src/main/java/org/bukkit/PortalType.java new file mode 100644 index 00000000..a63dad23 --- /dev/null +++ b/src/main/java/org/bukkit/PortalType.java @@ -0,0 +1,21 @@ +package org.bukkit; + +/** + * Represents various types of portals that can be made in a world. + */ +public enum PortalType { + /** + * This is a Nether portal, made of obsidian. + */ + NETHER, + + /** + * This is an Ender portal. + */ + ENDER, + + /** + * This is a custom Plugin portal. + */ + CUSTOM; +} diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index d2114318..08250268 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -745,6 +745,12 @@ public abstract class Event implements Serializable { * @see org.bukkit.event.entity.FoodLevelChangeEvent */ FOOD_LEVEL_CHANGE(Category.LIVING_ENTITY), + /** + * Called when an entity creates a portal in a world + * + * @see org.bukkit.event.entity.EntityCreatePortalEvent + */ + ENTITY_CREATE_PORTAL(Category.LIVING_ENTITY), /** * WEATHER EVENTS diff --git a/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java b/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java new file mode 100644 index 00000000..37712ea6 --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java @@ -0,0 +1,49 @@ +package org.bukkit.event.entity; + +import java.util.List; +import org.bukkit.PortalType; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; + +/** + * Thrown when a Living Entity creates a portal in a world. + */ +public class EntityCreatePortalEvent extends EntityEvent implements Cancellable { + private List<BlockState> blocks; + private boolean cancelled = false; + private PortalType type = PortalType.CUSTOM; + + public EntityCreatePortalEvent(Entity what, List<BlockState> blocks, PortalType type) { + super(Type.ENTITY_CREATE_PORTAL, what); + + this.blocks = blocks; + this.type = type; + } + + /** + * Gets a list of all blocks associated with the portal. + * + * @return List of blocks that will be changed. + */ + public List<BlockState> getBlocks() { + return blocks; + } + + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancel) { + this.cancelled = true; + } + + /** + * Gets the type of portal that is trying to be created. + * + * @return Type of portal. + */ + public PortalType getPortalType() { + return type; + } +} diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java index 1e34b890..95f80077 100644 --- a/src/main/java/org/bukkit/event/entity/EntityListener.java +++ b/src/main/java/org/bukkit/event/entity/EntityListener.java @@ -169,4 +169,11 @@ public class EntityListener implements Listener { * @param event Relevant event details */ public void onItemDespawn(ItemDespawnEvent event) {} + + /** + * Called when an entity creates a portal. + * + * @param event Relevant event details + */ + public void onEntityCreatePortalEvent(EntityCreatePortalEvent event) {} } diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index bccc0c13..b73c46b4 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -763,6 +763,13 @@ public class JavaPluginLoader implements PluginLoader { } }; + case ENTITY_CREATE_PORTAL: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((EntityListener) listener).onEntityCreatePortalEvent((EntityCreatePortalEvent) event); + } + }; + case CREATURE_SPAWN: return new EventExecutor() { public void execute(Listener listener, Event event) { |