[Bleeding] Added getting and setting drops to all appropriate events. Fixes BUKKIT-397 and fixes BUKKIT-1252

By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
Bukkit/Spigot
2011-08-14 22:34:13 -04:00
parent da44559df3
commit bbe996077c
6 changed files with 68 additions and 7 deletions

View File

@@ -1,9 +1,12 @@
package org.bukkit.event.block;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Called when a block is broken by a player.
@@ -19,11 +22,13 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player player;
private boolean cancel;
private List<ItemStack> drops;
public BlockBreakEvent(final Block theBlock, final Player player) {
public BlockBreakEvent(final Block theBlock, final Player player, List<ItemStack> drops) {
super(theBlock);
this.player = player;
this.cancel = false;
this.drops = drops;
}
/**
@@ -35,6 +40,16 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable {
return player;
}
/**
* Gets a list of items that should drop from this block. Modifying this list will modify the items drop.
* If the block is a container, the contents of the container will not be included in this list. You can
* get the contents of the container by casting the block's state.
* @return A list of drops
*/
public List<ItemStack> getDrops() {
return drops;
}
public boolean isCancelled() {
return cancel;
}