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:
Bukkit/Spigot 2019-02-24 20:19:09 -05:00
parent 4607199e45
commit eba047f8db

View File

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