diff options
author | feildmaster <admin@feildmaster.com> | 2012-12-07 19:12:32 -0600 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-12-09 00:31:23 -0600 |
commit | 7631c22aeaadb9ae6a216f81e32a9c4b4bab04eb (patch) | |
tree | ee6aff3e62d872b9ca1492ee545e34bdf001d0c1 | |
parent | 2ea133bb9923015f1c07217440840a1eb18a4385 (diff) | |
download | bukkit-7631c22aeaadb9ae6a216f81e32a9c4b4bab04eb.tar bukkit-7631c22aeaadb9ae6a216f81e32a9c4b4bab04eb.tar.gz bukkit-7631c22aeaadb9ae6a216f81e32a9c4b4bab04eb.tar.lz bukkit-7631c22aeaadb9ae6a216f81e32a9c4b4bab04eb.tar.xz bukkit-7631c22aeaadb9ae6a216f81e32a9c4b4bab04eb.zip |
Add FurnaceExtractEvent. Addresses BUKKIT-2114
Added a "BlockExpEvent" to hold experience and the handlers for the events
3 files changed, 96 insertions, 32 deletions
diff --git a/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/src/main/java/org/bukkit/event/block/BlockBreakEvent.java index a5533007..263cf36e 100644 --- a/src/main/java/org/bukkit/event/block/BlockBreakEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -23,15 +23,13 @@ import org.bukkit.event.HandlerList; * <p /> * If a Block Break event is cancelled, the block will not break and experience will not drop. */ -public class BlockBreakEvent extends BlockEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); +public class BlockBreakEvent extends BlockExpEvent implements Cancellable { private final Player player; private boolean cancel; - private int exp; public BlockBreakEvent(final Block theBlock, final Player player) { - super(theBlock); + super(theBlock, 0); + this.player = player; } @@ -44,24 +42,6 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable { return player; } - /** - * Get the experience to drop after the block is broken. - * - * @return The experience to drop - */ - public int getExpToDrop() { - return exp; - } - - /** - * Set the amount of experience to drop after the block is broken. - * - * @param exp 1 or higher to drop experience, or else nothing will drop - */ - public void setExpToDrop(int exp) { - this.exp = exp; - } - public boolean isCancelled() { return cancel; } @@ -69,13 +49,4 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } } diff --git a/src/main/java/org/bukkit/event/block/BlockExpEvent.java b/src/main/java/org/bukkit/event/block/BlockExpEvent.java new file mode 100644 index 00000000..94ec5391 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/BlockExpEvent.java @@ -0,0 +1,44 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; + +/** + * An event that's called when a block yields experience. + */ +public class BlockExpEvent extends BlockEvent { + private static final HandlerList handlers = new HandlerList(); + private int exp; + + public BlockExpEvent(Block block, int exp) { + super(block); + + this.exp = exp; + } + + /** + * Get the experience dropped by the block after the event has processed + * + * @return The experience to drop + */ + public int getExpToDrop() { + return exp; + } + + /** + * Set the amount of experience dropped by the block after the event has processed + * + * @param exp 1 or higher to drop experience, else nothing will drop + */ + public void setExpToDrop(int exp) { + this.exp = exp; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java b/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java new file mode 100644 index 00000000..b7381fa1 --- /dev/null +++ b/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java @@ -0,0 +1,49 @@ +package org.bukkit.event.inventory; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockExpEvent; + +/** + * This event is called when a player takes items out of the furnace + */ +public class FurnaceExtractEvent extends BlockExpEvent { + private final Player player; + private final Material itemType; + private final int itemAmount; + + public FurnaceExtractEvent(Player player, Block block, Material itemType, int itemAmount, int exp) { + super(block, exp); + this.player = player; + this.itemType = itemType; + this.itemAmount = itemAmount; + } + + /** + * Get the player that triggered the event + * + * @return the relevant player + */ + public Player getPlayer() { + return player; + } + + /** + * Get the Material of the item being retrieved + * + * @return the material of the item + */ + public Material getItemType() { + return itemType; + } + + /** + * Get the item count being retrieved + * + * @return the amount of the item + */ + public int getItemAmount() { + return itemAmount; + } +} |