Yatopia/patches/api/0030-EMC-Add-a-BlockHarvestBeehiveEvent.patch

86 lines
2.3 KiB
Diff
Raw Normal View History

2020-02-26 20:12:29 +01:00
From 047f48d8320fb3b569464de9e2e7f8129ed114c0 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 00000000..39cc3a97
--- /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