diff options
author | Meaglin <meaglin.wasabi@gmail.com> | 2011-02-01 18:07:16 +0100 |
---|---|---|
committer | Meaglin <meaglin.wasabi@gmail.com> | 2011-02-01 18:07:16 +0100 |
commit | af9d2b86c35e4e59bc679e8909b28f6cbe6e3be1 (patch) | |
tree | c305847a02e762f08892b12cf806e77b490ff7ae /src | |
parent | fb9fdc518eca023073b549c2a9db6a0f5f0cf785 (diff) | |
download | bukkit-af9d2b86c35e4e59bc679e8909b28f6cbe6e3be1.tar bukkit-af9d2b86c35e4e59bc679e8909b28f6cbe6e3be1.tar.gz bukkit-af9d2b86c35e4e59bc679e8909b28f6cbe6e3be1.tar.lz bukkit-af9d2b86c35e4e59bc679e8909b28f6cbe6e3be1.tar.xz bukkit-af9d2b86c35e4e59bc679e8909b28f6cbe6e3be1.zip |
Interface for BlockBreakEvent
Diffstat (limited to 'src')
4 files changed, 59 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 0db91797..78bda147 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -320,6 +320,13 @@ public abstract class Event { REDSTONE_CHANGE (Category.BLOCK), /** + * Called when a block is destroyed by a player. + * + * @see org.bukkit.event.block.BlockBreakEvent + */ + BLOCK_BREAK (Category.BLOCK), + + /** * INVENTORY EVENTS */ diff --git a/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/src/main/java/org/bukkit/event/block/BlockBreakEvent.java new file mode 100644 index 00000000..81efd2a6 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -0,0 +1,39 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; + +/** + * + * @author Meaglin + */ +public class BlockBreakEvent extends BlockEvent implements Cancellable { + + private Player player; + private boolean cancel; + + public BlockBreakEvent(final Block theBlock, Player player) { + super(Event.Type.BLOCK_BREAK, theBlock); + this.player = player; + this.cancel = false; + } + + /** + * Returns the player doing the damage + * + * @return + */ + public Player getPlayer() { + return player; + } + + 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 ff998b18..7b7305f2 100644 --- a/src/main/java/org/bukkit/event/block/BlockListener.java +++ b/src/main/java/org/bukkit/event/block/BlockListener.java @@ -101,4 +101,12 @@ public class BlockListener implements Listener { */ public void onBlockBurn(BlockBurnEvent event) { } + + /** + * Called when a block is destroyed by a player. + * + * @param event Relevant event details + */ + public void onBlockBreak(BlockBreakEvent event) { + } } diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 064739b1..9c733258 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -235,12 +235,16 @@ public final class JavaPluginLoader implements PluginLoader { ((BlockListener)listener).onBlockRedstoneChange( (BlockFromToEvent)event ); } }; - case BLOCK_BURN: return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockBurn( (BlockBurnEvent)event ); } }; + case BLOCK_BREAK: + return new EventExecutor() { public void execute( Listener listener, Event event ) { + ((BlockListener)listener).onBlockBreak( (BlockBreakEvent)event ); + } + }; // Server Events case PLUGIN_ENABLE: |