diff options
Diffstat (limited to 'src/main')
8 files changed, 198 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java b/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java new file mode 100644 index 00000000..80851ed0 --- /dev/null +++ b/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java @@ -0,0 +1,25 @@ +package org.bukkit.event.hanging; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Hanging; + +/** + * Triggered when a hanging entity is removed by an entity + */ +public class HangingBreakByEntityEvent extends HangingBreakEvent { + private final Entity remover; + + public HangingBreakByEntityEvent(final Hanging hanging, final Entity remover) { + super(hanging, HangingBreakEvent.RemoveCause.ENTITY); + this.remover = remover; + } + + /** + * Gets the entity that removed the hanging entity + * + * @return the entity that removed the hanging entity + */ + public Entity getRemover() { + return remover; + } +} diff --git a/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java b/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java new file mode 100644 index 00000000..ef655dbf --- /dev/null +++ b/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java @@ -0,0 +1,63 @@ +package org.bukkit.event.hanging; + +import org.bukkit.entity.Hanging; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Triggered when a hanging entity is removed + */ +public class HangingBreakEvent extends HangingEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + private final HangingBreakEvent.RemoveCause cause; + + public HangingBreakEvent(final Hanging hanging, final HangingBreakEvent.RemoveCause cause) { + super(hanging); + this.cause = cause; + } + + /** + * Gets the cause for the hanging entity's removal + * + * @return the RemoveCause for the hanging entity's removal + */ + public HangingBreakEvent.RemoveCause getCause() { + return cause; + } + + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + /** + * An enum to specify the cause of the removal + */ + public enum RemoveCause { + /** + * Removed by an entity + */ + ENTITY, + /** + * Removed by placing a block on it + */ + OBSTRUCTION, + /** + * Removed by destroying the block behind it, etc + */ + PHYSICS, + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/org/bukkit/event/hanging/HangingEvent.java b/src/main/java/org/bukkit/event/hanging/HangingEvent.java new file mode 100644 index 00000000..b370afe7 --- /dev/null +++ b/src/main/java/org/bukkit/event/hanging/HangingEvent.java @@ -0,0 +1,24 @@ +package org.bukkit.event.hanging; + +import org.bukkit.entity.Hanging; +import org.bukkit.event.Event; + +/** + * Represents a hanging entity-related event. + */ +public abstract class HangingEvent extends Event { + protected Hanging hanging; + + protected HangingEvent(final Hanging painting) { + this.hanging = painting; + } + + /** + * Gets the hanging entity involved in this event. + * + * @return the hanging entity + */ + public Hanging getEntity() { + return hanging; + } +} diff --git a/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java b/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java new file mode 100644 index 00000000..b511c555 --- /dev/null +++ b/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java @@ -0,0 +1,70 @@ +package org.bukkit.event.hanging; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Triggered when a hanging entity is created in the world + */ +public class HangingPlaceEvent extends HangingEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + private final Player player; + private final Block block; + private final BlockFace blockFace; + + public HangingPlaceEvent(final Hanging hanging, final Player player, final Block block, final BlockFace blockFace) { + super(hanging); + this.player = player; + this.block = block; + this.blockFace = blockFace; + } + + /** + * Returns the player placing the hanging entity + * + * @return the player placing the hanging entity + */ + public Player getPlayer() { + return player; + } + + /** + * Returns the block that the hanging entity was placed on + * + * @return the block that the hanging entity was placed on + */ + public Block getBlock() { + return block; + } + + /** + * Returns the face of the block that the hanging entity was placed on + * + * @return the face of the block that the hanging entity was placed on + */ + public BlockFace getBlockFace() { + return blockFace; + } + + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/org/bukkit/event/painting/PaintingBreakByEntityEvent.java b/src/main/java/org/bukkit/event/painting/PaintingBreakByEntityEvent.java index d7f0bb16..91aa8f2f 100644 --- a/src/main/java/org/bukkit/event/painting/PaintingBreakByEntityEvent.java +++ b/src/main/java/org/bukkit/event/painting/PaintingBreakByEntityEvent.java @@ -1,11 +1,15 @@ package org.bukkit.event.painting; +import org.bukkit.Warning; import org.bukkit.entity.Entity; import org.bukkit.entity.Painting; /** * Triggered when a painting is removed by an entity + * @deprecated Use {@link org.bukkit.event.hanging.HangingBreakByEntityEvent} instead. */ +@Deprecated +@Warning(reason="This event has been replaced by HangingBreakByEntityEvent") public class PaintingBreakByEntityEvent extends PaintingBreakEvent { private final Entity remover; diff --git a/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java b/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java index edf3559c..e822d15c 100644 --- a/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java +++ b/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java @@ -1,12 +1,16 @@ package org.bukkit.event.painting; +import org.bukkit.Warning; import org.bukkit.entity.Painting; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; /** * Triggered when a painting is removed + * @deprecated Use {@link org.bukkit.event.hanging.HangingBreakEvent} instead. */ +@Deprecated +@Warning(reason="This event has been replaced by HangingBreakEvent") public class PaintingBreakEvent extends PaintingEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; diff --git a/src/main/java/org/bukkit/event/painting/PaintingEvent.java b/src/main/java/org/bukkit/event/painting/PaintingEvent.java index 4e5553f6..f942bb4d 100644 --- a/src/main/java/org/bukkit/event/painting/PaintingEvent.java +++ b/src/main/java/org/bukkit/event/painting/PaintingEvent.java @@ -1,11 +1,15 @@ package org.bukkit.event.painting; +import org.bukkit.Warning; import org.bukkit.entity.Painting; import org.bukkit.event.Event; /** * Represents a painting-related event. + * @deprecated Use {@link org.bukkit.event.hanging.HangingEvent} instead. */ +@Deprecated +@Warning(reason="This event has been replaced by HangingEvent") public abstract class PaintingEvent extends Event { protected Painting painting; diff --git a/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java b/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java index 7e442d9a..914f9a3a 100644 --- a/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java +++ b/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.painting; +import org.bukkit.Warning; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Painting; @@ -9,7 +10,10 @@ import org.bukkit.event.HandlerList; /** * Triggered when a painting is created in the world + * @deprecated Use {@link org.bukkit.event.hanging.HangingPlaceEvent} instead. */ +@Deprecated +@Warning(reason="This event has been replaced by HangingPlaceEvent") public class PaintingPlaceEvent extends PaintingEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; |