Paper/patches/api/0309-Add-BlockBreakBlockEve...

74 lines
2.0 KiB
Diff
Raw Normal View History

2021-08-25 03:42:23 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 3 Jan 2021 17:58:25 -0800
Subject: [PATCH] Add BlockBreakBlockEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..4f7535daf0d9967fadb0c6f8afbd3993eace410d
2021-08-25 03:42:23 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,61 @@
2021-08-25 03:42:23 +02:00
+package io.papermc.paper.event.block;
+
+import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExpEvent;
2021-08-25 03:42:23 +02:00
+import org.bukkit.inventory.ItemStack;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-08-25 03:42:23 +02:00
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * Called when a block forces another block to break and drop items.
+ * <p>
+ * Currently called for piston's and liquid flows.
+ */
+public class BlockBreakBlockEvent extends BlockExpEvent {
2021-08-25 03:42:23 +02:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Block source;
2024-02-01 10:15:57 +01:00
+ private final List<ItemStack> drops;
2021-08-25 03:42:23 +02:00
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
2021-08-25 03:42:23 +02:00
+ public BlockBreakBlockEvent(@NotNull Block block, @NotNull Block source, @NotNull List<ItemStack> drops) {
+ super(block, 0);
2021-08-25 03:42:23 +02:00
+ this.source = source;
+ this.drops = drops;
+ }
+
+ /**
2024-02-01 10:15:57 +01:00
+ * Gets the drops of this event
2021-08-25 03:42:23 +02:00
+ *
+ * @return the drops
+ */
+ @NotNull
+ public List<ItemStack> getDrops() {
2024-02-01 10:15:57 +01:00
+ return this.drops;
2021-08-25 03:42:23 +02:00
+ }
+
+ /**
+ * Gets the block that cause this (e.g. a piston, or adjacent liquid)
+ *
+ * @return the source
+ */
+ @NotNull
+ public Block getSource() {
2024-02-01 10:15:57 +01:00
+ return this.source;
2021-08-25 03:42:23 +02:00
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}