diff options
author | AndaBlock <anda.block12345@outlook.de> | 2018-10-31 17:57:02 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-10-31 19:54:26 +1100 |
commit | 98d3f031c31269cf6997d3c4a92bb36620ad4731 (patch) | |
tree | 1549f4efe94c3465171987f0e75c0977812f6890 /src | |
parent | 99934bd88a6b2976695d03cffddd4d4bba75ef66 (diff) | |
download | bukkit-98d3f031c31269cf6997d3c4a92bb36620ad4731.tar bukkit-98d3f031c31269cf6997d3c4a92bb36620ad4731.tar.gz bukkit-98d3f031c31269cf6997d3c4a92bb36620ad4731.tar.lz bukkit-98d3f031c31269cf6997d3c4a92bb36620ad4731.tar.xz bukkit-98d3f031c31269cf6997d3c4a92bb36620ad4731.zip |
SPIGOT-4376: Add draft BlockDropItemEvent
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/event/block/BlockDropItemEvent.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java new file mode 100644 index 00000000..b6e840a4 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java @@ -0,0 +1,94 @@ +package org.bukkit.event.block; + +import org.bukkit.Warning; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Called if a block broken by a player drops an item. + * + * If the block break is cancelled, this event won't be called. + * + * If isDropItems in BlockBreakEvent is set to false, this event won't be + * called. + * + * This event will also be called if the player breaks a multi block structure, + * for example a torch on top of a stone. Both items will have an event call. + * + * The Block is already broken as this event is called, so #getBlock() will be + * AIR in most cases. Use #getBlockData() for more Information about the broken + * block. + * + * <b>Note this event may not currently fire for some drops associated with tile + * entities</b> + * + * @deprecated draft API + */ +@Deprecated +@Warning(false) +public class BlockDropItemEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private final Player player; + private boolean cancel; + private final BlockState blockState; + private final Item item; + + public BlockDropItemEvent(Block block, BlockState blockState, Player player, Item item) { + super(block); + this.blockState = blockState; + this.player = player; + this.item = item; + } + + /** + * Gets the Player that is breaking the block involved in this event. + * + * @return The Player that is breaking the block involved in this event + */ + public Player getPlayer() { + return player; + } + + /** + * Gets the BlockState of the block involved in this event before it was + * broken. + * + * @return The BlockState of the block involved in this event + */ + public BlockState getBlockState() { + return blockState; + } + + /** + * Gets the Item drop caused by the block break. + * + * @return The Item the block caused to drop + */ + public Item getItem() { + return item; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} |