80 lines
2.3 KiB
Diff
80 lines
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Sat, 9 Nov 2024 09:48:21 -0600
|
|
Subject: [PATCH] Add BlockDestroyedByNeighborEvent
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java b/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7db2789d54a609b023ea6deff87b45d717aabbf0
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java
|
|
@@ -0,0 +1,67 @@
|
|
+package io.papermc.paper.event.block;
|
|
+
|
|
+import org.bukkit.block.Block;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.block.BlockEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import org.jetbrains.annotations.Nullable;
|
|
+
|
|
+/**
|
|
+ * Called when a block is broken another block. This is generally the result of BlockPhysicsEvent propagation
|
|
+ */
|
|
+public class BlockDestroyedByNeighborEvent extends BlockEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private final Player player;
|
|
+ private final Block sourceBlock;
|
|
+ private boolean cancel;
|
|
+
|
|
+ public BlockDestroyedByNeighborEvent(@NotNull final Block theBlock, @Nullable Player player, @NotNull final Block sourceBlock) {
|
|
+ super(theBlock);
|
|
+
|
|
+ this.player = player;
|
|
+ this.sourceBlock = sourceBlock;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the Player that caused this
|
|
+ *
|
|
+ * @return The Player that is breaking the block involved in this event
|
|
+ */
|
|
+ @Nullable
|
|
+ public Player getPlayer() {
|
|
+ return player;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the source block that caused this block break
|
|
+ *
|
|
+ * @return The Source Block which block is involved in this event
|
|
+ */
|
|
+ @NotNull
|
|
+ public final Block getSourceBlock() {
|
|
+ return sourceBlock;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ this.cancel = cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|