diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-03-23 16:53:52 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-03-23 16:58:43 +0100 |
commit | d6341293e77cfd51260ff130454e51db182bbc21 (patch) | |
tree | 2cc3f478801f880877fd322f8380e1e02801d4f0 /src/main | |
parent | 700c8a20ddfdafa98767ff587a0692e4449f16ff (diff) | |
download | bukkit-d6341293e77cfd51260ff130454e51db182bbc21.tar bukkit-d6341293e77cfd51260ff130454e51db182bbc21.tar.gz bukkit-d6341293e77cfd51260ff130454e51db182bbc21.tar.lz bukkit-d6341293e77cfd51260ff130454e51db182bbc21.tar.xz bukkit-d6341293e77cfd51260ff130454e51db182bbc21.zip |
Reworked BlockDamageEvent to match with the latest Mojang client/server changes.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/block/BlockDamageLevel.java | 15 | ||||
-rw-r--r-- | src/main/java/org/bukkit/event/block/BlockDamageEvent.java | 37 |
2 files changed, 28 insertions, 24 deletions
diff --git a/src/main/java/org/bukkit/block/BlockDamageLevel.java b/src/main/java/org/bukkit/block/BlockDamageLevel.java deleted file mode 100644 index 65fb73ba..00000000 --- a/src/main/java/org/bukkit/block/BlockDamageLevel.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.bukkit.block; - -public enum BlockDamageLevel { - STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2); - - private int level; - - private BlockDamageLevel(final int level) { - this.level = level; - } - - public int getLevel() { - return level; - } -} diff --git a/src/main/java/org/bukkit/event/block/BlockDamageEvent.java b/src/main/java/org/bukkit/event/block/BlockDamageEvent.java index edf332cf..d3a3a8e9 100644 --- a/src/main/java/org/bukkit/event/block/BlockDamageEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockDamageEvent.java @@ -1,22 +1,24 @@ package org.bukkit.event.block; import org.bukkit.block.Block; -import org.bukkit.block.BlockDamageLevel; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.inventory.ItemStack; /** * @author tkelly */ public class BlockDamageEvent extends BlockEvent implements Cancellable { private Player player; - private BlockDamageLevel damageLevel; + private boolean instaBreak; private boolean cancel; + private ItemStack itemstack; - public BlockDamageEvent(Type type, Block block, BlockDamageLevel level, Player player) { - super(type, block); - this.damageLevel = level; + public BlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) { + super(Type.BLOCK_DAMAGE, block); + this.instaBreak = instaBreak; this.player = player; + this.itemstack = itemstack; this.cancel = false; } @@ -30,13 +32,30 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { } /** - * Returns the level of damage to the block + * Returns if the block is set to instantly break * - * @return + * @return boolean If the block should instantly break + */ + public boolean getInstaBreak() { + return instaBreak; + } + + /** + * Set if the block should instantly break + */ + public void setInstaBreak(boolean bool) { + this.instaBreak = bool; + } + + /** + * Returns the ItemStack in hand + * + * @return Currently wielding itemstack */ - public BlockDamageLevel getDamageLevel() { - return damageLevel; + public ItemStack getItemInHand() { + return itemstack; } + public boolean isCancelled() { return cancel; |