Paper/patches/api/0107-WitchReadyPotionEvent....

82 lines
2.3 KiB
Diff
Raw Permalink Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Jun 2018 22:47:08 -0400
Subject: [PATCH] WitchReadyPotionEvent
Control what potion the witch readies to use
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..7feca06e72bd585bbfa219df38a2161b77e8d4c4
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,68 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Witch;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class WitchReadyPotionEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2021-06-11 14:02:28 +02:00
+ private ItemStack potion;
2024-02-01 10:15:57 +01:00
+ private boolean cancelled;
2021-06-11 14:02:28 +02:00
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public WitchReadyPotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) {
+ super(witch);
+ this.potion = potion;
+ }
+
+ @NotNull
+ @Override
+ public Witch getEntity() {
+ return (Witch) super.getEntity();
+ }
+
+ /**
+ * @return the potion the witch is readying to use
+ */
+ @Nullable
+ public ItemStack getPotion() {
2024-02-01 10:15:57 +01:00
+ return this.potion;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Sets the potion the which is going to hold and use
2024-02-01 10:15:57 +01:00
+ *
2021-06-11 14:02:28 +02:00
+ * @param potion The potion
+ */
+ public void setPotion(@Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null;
+ }
+
2024-02-01 10:15:57 +01:00
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @NotNull
2021-06-11 14:02:28 +02:00
+ @Override
2024-02-01 10:15:57 +01:00
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+}