mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
SPIGOT-4637: Add source block to BlockPhysicsEvent.
Allows a plugin to lookup the source block of event. For example, a protection plugin may want to determine what caused the physics event to be triggered. By: bloodshot <jdroque@gmail.com>
This commit is contained in:
parent
4607199e45
commit
eba047f8db
@ -28,11 +28,28 @@ import org.bukkit.event.HandlerList;
|
||||
public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final BlockData changed;
|
||||
private final Block sourceBlock;
|
||||
private boolean cancel = false;
|
||||
|
||||
public BlockPhysicsEvent(final Block block, final BlockData changed) {
|
||||
this(block, changed, block);
|
||||
}
|
||||
|
||||
public BlockPhysicsEvent(final Block block, final BlockData changed, final Block sourceBlock) {
|
||||
super(block);
|
||||
this.changed = changed;
|
||||
this.sourceBlock = sourceBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source block that triggered this event.
|
||||
*
|
||||
* Note: This will default to block if not set.
|
||||
*
|
||||
* @return The source block
|
||||
*/
|
||||
public Block getSourceBlock() {
|
||||
return sourceBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user