Yatopia/patches/api/0027-EMC-Add-a-BlockHarvestBeehiveEvent.patch
2020-05-12 19:47:53 +02:00

86 lines
2.3 KiB
Diff

From b9c9eece57661111616724185fe0c0e5b34e5f35 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Fri, 17 Jan 2020 21:27:29 -0600
Subject: [PATCH] EMC Add a BlockHarvestBeehiveEvent
---
.../BlockHarvestBeehiveEvent.java | 66 +++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 src/main/java/com/empireminecraft/customevents/BlockHarvestBeehiveEvent.java
diff --git a/src/main/java/com/empireminecraft/customevents/BlockHarvestBeehiveEvent.java b/src/main/java/com/empireminecraft/customevents/BlockHarvestBeehiveEvent.java
new file mode 100644
index 000000000..39cc3a973
--- /dev/null
+++ b/src/main/java/com/empireminecraft/customevents/BlockHarvestBeehiveEvent.java
@@ -0,0 +1,66 @@
+package com.empireminecraft.customevents;
+
+import org.bukkit.block.Block;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Event fired when a dispenser harvests a nearby beehive.
+ */
+public class BlockHarvestBeehiveEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+
+ private final Block beehive;
+ private final ItemStack tool;
+ private boolean cancelled;
+
+ public BlockHarvestBeehiveEvent(@NotNull Block dispenser, @NotNull Block beehive, @NotNull ItemStack tool) {
+ super(dispenser);
+ this.beehive = beehive;
+ this.tool = tool;
+ }
+
+ /**
+ * Gets the beehive that was harvested.
+ *
+ * @return the beehive that was harvested.
+ */
+ @NotNull
+ public Block getBeehive() {
+ return beehive;
+ }
+
+ /**
+ * Gets the item used to harvest the beehive.
+ *
+ * @return the item used to harvest the beehive.
+ */
+ @NotNull
+ public ItemStack getTool() {
+ return tool.clone();
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
--
2.25.1.windows.1