diff options
5 files changed, 68 insertions, 21 deletions
diff --git a/src/main/java/org/bukkit/BlockDamageLevel.java b/src/main/java/org/bukkit/BlockDamageLevel.java new file mode 100644 index 00000000..bb8e4b23 --- /dev/null +++ b/src/main/java/org/bukkit/BlockDamageLevel.java @@ -0,0 +1,15 @@ +package org.bukkit; + +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/BlockBrokenEvent.java b/src/main/java/org/bukkit/event/block/BlockBrokenEvent.java deleted file mode 100644 index ec064865..00000000 --- a/src/main/java/org/bukkit/event/block/BlockBrokenEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.bukkit.event.block; - -import org.bukkit.Block; -import org.bukkit.Player; - -/** - * Not implemented yet - */ -public class BlockBrokenEvent extends BlockEvent { - private Player player; - - public BlockBrokenEvent(Type type, Block block ) { - super(type, block); - } - - public Player getPlayer() { - return player; - } -} diff --git a/src/main/java/org/bukkit/event/block/BlockDamagedEvent.java b/src/main/java/org/bukkit/event/block/BlockDamagedEvent.java new file mode 100644 index 00000000..5586f846 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/BlockDamagedEvent.java @@ -0,0 +1,48 @@ +package org.bukkit.event.block; + +import org.bukkit.Block; +import org.bukkit.BlockDamageLevel; +import org.bukkit.Player; +import org.bukkit.event.Cancellable; + +/** + * @author tkelly + */ +public class BlockDamagedEvent extends BlockEvent implements Cancellable { + private Player player; + private BlockDamageLevel damageLevel; + private boolean cancel; + + public BlockDamagedEvent(Type type, Block block, BlockDamageLevel level, Player player) { + super(type, block); + this.damageLevel = level; + this.player = player; + this.cancel = false; + } + + /** + * Returns the player doing the damage + * + * @return + */ + public Player getPlayer() { + return player; + } + + /** + * Returns the level of damage to the block + * + * @return + */ + public BlockDamageLevel getDamageLevel() { + return damageLevel; + } + + public boolean isCancelled() { + return cancel; + } + + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } +} diff --git a/src/main/java/org/bukkit/event/block/BlockListener.java b/src/main/java/org/bukkit/event/block/BlockListener.java index d7ee313e..f7ef3738 100644 --- a/src/main/java/org/bukkit/event/block/BlockListener.java +++ b/src/main/java/org/bukkit/event/block/BlockListener.java @@ -15,11 +15,11 @@ public class BlockListener implements Listener { }
/**
- * Called when a block is broken (or destroyed)
+ * Called when a block is damaged (or broken)
*
* @param event Relevant event details
*/
- public void onBlockBroken(BlockBrokenEvent event) {
+ public void onBlockDamaged(BlockDamagedEvent event) {
}
/**
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 75d4d91c..1a5b9210 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -132,6 +132,9 @@ public final class JavaPluginLoader implements PluginLoader { case BLOCK_PLACED: trueListener.onBlockPlaced((BlockPlacedEvent)event); break; + case BLOCK_DAMAGED: + trueListener.onBlockDamaged((BlockDamagedEvent)event); + break; case BLOCK_INTERACT: trueListener.onBlockInteracted((BlockInteractEvent)event); break; |