mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
Add support for preventing block drops in BreakEvent
By: Scetra <contact@scetra.me>
This commit is contained in:
parent
701901f64b
commit
db19779164
1 changed files with 20 additions and 0 deletions
|
@ -28,12 +28,14 @@ import org.bukkit.event.HandlerList;
|
|||
*/
|
||||
public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
|
||||
private final Player player;
|
||||
private boolean dropItems;
|
||||
private boolean cancel;
|
||||
|
||||
public BlockBreakEvent(final Block theBlock, final Player player) {
|
||||
super(theBlock, 0);
|
||||
|
||||
this.player = player;
|
||||
this.dropItems = true; // Defaults to dropping items as it normally would
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +47,24 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
|
|||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the block will drop items as it normally would.
|
||||
*
|
||||
* @param dropItems Whether or not the block will drop items
|
||||
*/
|
||||
public void setDropItems(boolean dropItems) {
|
||||
this.dropItems = dropItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not the block will drop items.
|
||||
*
|
||||
* @return Whether or not the block will drop items
|
||||
*/
|
||||
public boolean isDropItems() {
|
||||
return this.dropItems;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue