From b7b10ad1c3cd0c03c041e2958a37895ce6990f65 Mon Sep 17 00:00:00 2001 From: Articdive Date: Mon, 23 Jul 2018 17:04:09 +1000 Subject: SPIGOT-824: SpongeAbsorbEvent --- .../org/bukkit/event/block/SpongeAbsorbEvent.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java b/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java new file mode 100644 index 00000000..2611d069 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java @@ -0,0 +1,60 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import java.util.List; +import org.bukkit.Material; + +/** + * Called when a sponge absorbs water from the world. + *
+ * The world will be in its previous state, and {@link #getBlocks()} will + * represent the changes to be made to the world, if the event is not cancelled. + *
+ * As this is a physics based event it may be called multiple times for "the + * same" changes. + */ +public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + private final List blocks; + + public SpongeAbsorbEvent(Block block, List waterblocks) { + super(block); + this.blocks = waterblocks; + } + + /** + * Get a list of all blocks to be removed by the sponge. + *
+ * This list is mutable and contains the blocks in their removed state, i.e. + * having a type of {@link Material#AIR}. + * + * @return list of the to be removed blocks. + */ + public List getBlocks() { + return blocks; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} -- cgit v1.2.3