mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
179 lines
5.1 KiB
Diff
179 lines
5.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
|
Date: Mon, 25 Jul 2022 19:33:49 +0200
|
|
Subject: [PATCH] Add Bee API
|
|
|
|
|
|
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7f631a41abee4640a37339a7896ce96e61747735
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java
|
|
@@ -0,0 +1,48 @@
|
|
+package org.purpurmc.purpur.event.entity;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.entity.Bee;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jspecify.annotations.NullMarked;
|
|
+import org.jspecify.annotations.Nullable;
|
|
+
|
|
+/**
|
|
+ * Called when a bee targets a flower
|
|
+ */
|
|
+@NullMarked
|
|
+public class BeeFoundFlowerEvent extends EntityEvent {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private final Location location;
|
|
+
|
|
+ @ApiStatus.Internal
|
|
+ public BeeFoundFlowerEvent(Bee bee, @Nullable Location location) {
|
|
+ super(bee);
|
|
+ this.location = location;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Bee getEntity() {
|
|
+ return (Bee) super.getEntity();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the location of the flower that the bee targets
|
|
+ *
|
|
+ * @return The location of the flower
|
|
+ */
|
|
+ @Nullable
|
|
+ public Location getLocation() {
|
|
+ return location;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..e260145d6dc556bbe9e3654296b965c4e393084d
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java
|
|
@@ -0,0 +1,46 @@
|
|
+package org.purpurmc.purpur.event.entity;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.entity.Bee;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jspecify.annotations.NullMarked;
|
|
+
|
|
+/**
|
|
+ * Called when a bee starts pollinating
|
|
+ */
|
|
+@NullMarked
|
|
+public class BeeStartedPollinatingEvent extends EntityEvent {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private final Location location;
|
|
+
|
|
+ @ApiStatus.Internal
|
|
+ public BeeStartedPollinatingEvent(Bee bee, Location location) {
|
|
+ super(bee);
|
|
+ this.location = location;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Bee getEntity() {
|
|
+ return (Bee) super.getEntity();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the location of the flower that the bee pollinates
|
|
+ *
|
|
+ * @return The location of the flower
|
|
+ */
|
|
+ public Location getLocation() {
|
|
+ return this.location;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..8b2b351d620c749cdf58d7e824b55cf55578fde6
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java
|
|
@@ -0,0 +1,60 @@
|
|
+package org.purpurmc.purpur.event.entity;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.entity.Bee;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jspecify.annotations.NullMarked;
|
|
+import org.jspecify.annotations.Nullable;
|
|
+
|
|
+/**
|
|
+ * Called when a bee stops pollinating
|
|
+ */
|
|
+@NullMarked
|
|
+public class BeeStopPollinatingEvent extends EntityEvent {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private final Location location;
|
|
+ private final boolean success;
|
|
+
|
|
+ @ApiStatus.Internal
|
|
+ public BeeStopPollinatingEvent(Bee bee, @Nullable Location location, boolean success) {
|
|
+ super(bee);
|
|
+ this.location = location;
|
|
+ this.success = success;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Bee getEntity() {
|
|
+ return (Bee) super.getEntity();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the location of the flower that the bee stopped pollinating
|
|
+ *
|
|
+ * @return The location of the flower
|
|
+ */
|
|
+ @Nullable
|
|
+ public Location getLocation() {
|
|
+ return location;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns whether the bee successfully pollinated the flower
|
|
+ *
|
|
+ * @return True if the pollination was successful
|
|
+ */
|
|
+ public boolean wasSuccessful() {
|
|
+ return success;
|
|
+ }
|
|
+
|
|
+
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|