From c520a96024beeb557ebccbc0f18a938a232635a1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 26 Jul 2018 20:44:03 +1000 Subject: Add draft BlockFertilizeEvent --- .../bukkit/event/block/BlockFertilizeEvent.java | 71 ++++++++++++++++++++++ .../org/bukkit/event/world/StructureGrowEvent.java | 4 +- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java diff --git a/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java b/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java new file mode 100644 index 00000000..ab21c9d2 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java @@ -0,0 +1,71 @@ +package org.bukkit.event.block; + +import java.util.List; +import org.bukkit.Warning; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.world.StructureGrowEvent; + +/** + * Called with the block changes resulting from a player fertilizing a given + * block with bonemeal. Will be called after the applicable + * {@link StructureGrowEvent}. + * + * @deprecated draft API + */ +@Deprecated +@Warning(false) +public class BlockFertilizeEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + // + private final Player player; + private final List blocks; + + public BlockFertilizeEvent(Block theBlock, Player player, List blocks) { + super(theBlock); + this.player = player; + this.blocks = blocks; + } + + /** + * Gets the player that triggered the fertilization. + * + * @return triggering player, or null if not applicable + */ + public Player getPlayer() { + return player; + } + + /** + * Gets a list of all blocks changed by the fertilization. + * + * @return list of all changed blocks + */ + public List getBlocks() { + return blocks; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/org/bukkit/event/world/StructureGrowEvent.java b/src/main/java/org/bukkit/event/world/StructureGrowEvent.java index 62d300d7..7bf82e39 100644 --- a/src/main/java/org/bukkit/event/world/StructureGrowEvent.java +++ b/src/main/java/org/bukkit/event/world/StructureGrowEvent.java @@ -69,9 +69,9 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { } /** - * Gets an ArrayList of all blocks associated with the structure. + * Gets a list of all blocks associated with the structure. * - * @return ArrayList of all blocks associated with the structure. + * @return list of all blocks associated with the structure. */ public List getBlocks() { return blocks; -- cgit v1.2.3