Interface for BlockBreakEvent

By: Meaglin <meaglin.wasabi@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-02-01 18:07:16 +01:00
parent c818125fb8
commit d7d0c66b75
4 changed files with 59 additions and 1 deletions

View File

@ -319,6 +319,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
*/

View File

@ -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;
}
}

View File

@ -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) {
}
}

View File

@ -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: