mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 09:17:36 +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 {
|
public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final BlockData changed;
|
private final BlockData changed;
|
||||||
|
private final Block sourceBlock;
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
|
||||||
public BlockPhysicsEvent(final Block block, final BlockData changed) {
|
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);
|
super(block);
|
||||||
this.changed = changed;
|
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