From eba047f8dba5b0a5eef777ade29d0ff479749eae Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 24 Feb 2019 20:19:09 -0500 Subject: [PATCH] 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 --- .../bukkit/event/block/BlockPhysicsEvent.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java index 5e47eabe83..a34359ed37 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java @@ -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; } /**